body {
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.4;
    margin: 0;
    padding: 0;
    background-color: #f0f0f0;
    color: #000;
    height: 100vh;
    overflow: hidden;
}

.layout-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Left Panel Styles */
.left-panel {
    width: 50%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ccc;
    background: #fff;
    position: relative; /* For absolute positioning of code panel */
    overflow: hidden;
}

/* Header Section */
.panel-header {
    padding: 10px;
    background: #f8f8f8;
    border-bottom: 1px solid #ccc;
    flex-shrink: 0;
    z-index: 101; /* Above everything */
}

/* Top Section: Settings */
.settings-container {
    flex: 1; /* Take remaining space */
    height: auto; /* Override fixed height */
    overflow-y: auto;
    padding: 10px;
    padding-bottom: 50px; /* Space for collapsed code bar */
    border-bottom: none; /* Removed as code bar covers it */
}

.scrollable-content {
    max-width: 100%;
}

/* Bottom Section: Code */
.code-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #f5f5f5;
    z-index: 100;
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
}

.code-container.collapsed {
    height: 42px; /* Height of action bar */
}

.code-container.expanded {
    height: calc(100% - 46px); /* Full height minus header (approx) */
}

.actions-bar {
    padding: 5px 10px;
    background: #dcebf5; /* Slightly blue-ish to stand out but coordinate */
    border-bottom: 1px solid #b8cce4;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 32px; /* Fixed height for content */
    cursor: pointer;
    user-select: none;
}

.action-buttons {
    display: flex;
    gap: 5px;
}

.toggle-arrow {
    font-size: 14px;
    color: #555;
    margin-left: 10px;
    width: 20px;
    text-align: center;
}

textarea#outputCode {
    flex: 1;
    width: 100%;
    border: none;
    padding: 10px;
    font-family: monospace;
    font-size: 0.9em;
    resize: none;
    box-sizing: border-box;
    display: block; /* Always block, container height hides it */
}

/* Right Panel Styles */
.right-panel {
    width: 50%;
    display: flex;
    flex-direction: column;
    background: #525659; /* PDF viewer background color */
}

.status-bar {
    background: #333;
    color: #fff;
    padding: 5px 10px;
    font-size: 0.8em;
    height: 25px;
    display: flex;
    align-items: center;
}

.preview-wrapper {
    flex: 1;
    position: relative;
}

iframe#pdfPreview {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Common Styles for Settings Form */
h1 {
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    margin: 0; /* Reset margins for header */
}

h2 {
    font-size: 1em;
    font-weight: bold;
    margin: 15px 0 5px 0;
    color: #333;
    background: #eee;
    padding: 5px;
}

.section {
    margin-bottom: 10px;
}

.grid-row {
    display: grid;
    grid-template-columns: 180px 200px 1fr; /* Fixed width for middle column to align helpers */
    gap: 12px;
    margin-bottom: 8px;
    align-items: center;
}

.label {
    text-align: right;
    font-weight: 500;
    font-size: 13px;
    color: #555;
}

.input {
    display: flex;
    align-items: center;
    white-space: nowrap; /* Prevent wrapping of units */
    gap: 5px; /* Space between input and unit */
    /* Match label style */
    font-size: 13px;
    color: #555;
    font-weight: 500;
}

.input input[type="number"], .input input[type="text"], .input select {
    font-weight: normal;
    width: 140px; /* Fixed width for consistency */
    flex: 0 0 auto; /* Prevent growing/shrinking, strictly follow width */
    padding: 6px 8px; /* More comfortable padding */
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background-color: #fff;
    box-sizing: border-box;
    height: 32px; /* Consistent height */
}

.helper {
    color: #666;
    font-size: 0.75em;
    line-height: 1.2;
}

.red-text {
    color: red;
    font-weight: bold;
}

.wide-input-cell {
    grid-column: 2 / span 2;
    display: flex;
    align-items: center;
    gap: 5px;
}

.or-separator {
    color: #808080;
    font-size: 0.8em;
}

.action-btn {
    background-color: #f0f0f0;
    border: 1px solid #999;
    padding: 2px 8px;
    font-size: 0.85em;
    cursor: pointer;
    border-radius: 2px;
}

.action-btn:hover {
    background-color: #e0e0e0;
}

.action-btn:active {
    background-color: #ccc;
}

.calc-btn {
    background-color: #e0e0e0;
    border: 1px solid #999;
    font-size: 0.75em;
    padding: 1px 5px;
    cursor: pointer;
}

/* Custom summary marker for Advanced Settings */
details.section summary {
    list-style: none; /* Firefox/Standard */
}
details.section summary::-webkit-details-marker {
    display: none; /* Chrome/Safari */
}

details.section summary h2 {
    display: block;
    position: relative;
    cursor: pointer;
    padding-right: 30px; /* Space for arrow */
}

details.section summary h2::after {
    content: '◀'; /* Unicode arrow pointing Left */
    font-size: 0.8em;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.2s;
    display: inline-block;
}

details.section[open] summary h2::after {
    transform: translateY(-50%) rotate(-90deg); /* Rotate CCW to point Down */
}
