:root {
    --bg-color: #f0f0f0;
    --text-color: #333;
    --calculator-bg: #333;
    --display-bg: #e0e0e0;
    --button-num-bg: #555;
    --button-op-bg: #f0ad4e;
    --button-fn-bg: #5bc0de;
    --button-ctrl-bg: #888;
    --panel-bg: #fff;
    --panel-text-color: #333;
    --tab-bg: #ddd;
    --tab-active-bg: #fff;
    --gnb-bg: #222;
    --gnb-text: #fff;
    --gnb-hover: #444;
    --gnb-active: #5bc0de;
}

body.dark-mode {
    --bg-color: #1a1a1a;
    --text-color: #f0f0f0;
    --calculator-bg: #2c2c2c;
    --display-bg: #444;
    --button-num-bg: #666;
    --button-op-bg: #d9534f;
    --button-fn-bg: #31708f;
    --button-ctrl-bg: #555;
    --panel-bg: #2c2c2c;
    --panel-text-color: #f0f0f0;
    --tab-bg: #444;
    --tab-active-bg: #2c2c2c;
    --gnb-bg: #111;
    --gnb-hover: #333;
    --gnb-active: #31708f;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    display: flex; /* GNB Layout */
    height: 100vh;
    overflow: hidden; /* Prevent body scroll */
    transition: background-color 0.3s, color 0.3s;
}

/* --- GNB (Left Sidebar) --- */
.gnb {
    width: 250px;
    background-color: var(--gnb-bg);
    color: var(--gnb-text);
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    z-index: 100;
}

.gnb-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.gnb-header h1 {
    margin: 0;
    font-size: 24px;
    color: var(--gnb-active);
}

.gnb-menu {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    flex: 1;
}

.gnb-menu li {
    margin-bottom: 5px;
}

.gnb-btn {
    width: 100%;
    background: none;
    border: none;
    color: var(--gnb-text);
    text-align: left;
    padding: 15px 25px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    border-left: 4px solid transparent;
}

.gnb-btn:hover {
    background-color: var(--gnb-hover);
}

.gnb-btn.active {
    background-color: var(--gnb-hover);
    border-left-color: var(--gnb-active);
    font-weight: bold;
}

.gnb-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.theme-switcher { display: flex; align-items: center; justify-content: center; gap: 10px; }
.switch { position: relative; display: inline-block; width: 50px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #2196F3; }
input:checked + .slider:before { transform: translateX(26px); }


/* --- Main Content Area --- */
.page-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
}

.content-area {
    flex: 1;
    overflow-y: auto; /* Allow content to scroll */
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.main-menu-content {
    display: none;
    width: 100%;
    max-width: 1000px;
    animation: fadeEffect 0.5s;
}

.main-menu-content.active {
    display: block;
}

@keyframes fadeEffect {
    from {opacity: 0;}
    to {opacity: 1;}
}


/* --- 1. Server Time Menu --- */
/* Fixed layout breaking on server time page */
.server-time-container {
    background-color: var(--panel-bg);
    color: var(--panel-text-color);
    padding: 50px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    box-sizing: border-box; /* Prevent padding from breaking width */
}
.url-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}
#url-input {
    flex: 1;
    padding: 15px;
    font-size: 18px;
    border-radius: 5px;
    border: 1px solid #ccc;
    background-color: var(--display-bg);
    color: var(--text-color);
}
.large-time-display {
    font-size: 4rem;
    font-weight: bold;
    margin: 20px 0 10px 0;
    font-family: 'Courier New', Courier, monospace;
    color: #3e95cd;
    word-break: break-all;
}
.date-display {
    font-size: 1.2rem;
    opacity: 0.8;
    margin-bottom: 20px;
}
.time-desc { opacity: 0.7; }

/* --- 2. Calculator Menu --- */
.tabs {
    display: flex;
    width: 100%;
    margin-bottom: 0;
    z-index: 10;
}

.tab-btn {
    background-color: var(--tab-bg);
    color: var(--text-color);
    border: 1px solid transparent;
    border-bottom: none;
    padding: 12px 24px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 10px 10px 0 0;
    transition: background-color 0.3s, opacity 0.3s;
    opacity: 0.7;
    margin-right: 5px;
    font-weight: bold;
}

.tab-btn:hover { opacity: 1; }
.tab-btn.active {
    background-color: var(--panel-bg);
    opacity: 1;
    border-color: #ccc;
}
body.dark-mode .tab-btn.active {
    background-color: var(--panel-bg);
    border-color: #444;
}

.tab-content {
    display: none;
    width: 100%;
    border: 1px solid #ccc;
    border-top: none;
    padding: 20px;
    background-color: var(--panel-bg);
    border-radius: 0 10px 10px 10px;
    box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.05);
    box-sizing: border-box; /* Fix width issues */
}
body.dark-mode .tab-content { border-color: #444; }
.tab-content.active { display: block; }


.main-container {
    display: flex;
    gap: 20px;
    align-items: stretch;
    height: 600px;
    justify-content: center;
}

.calculator {
    background-color: var(--calculator-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.5);
    width: 700px;
    display: flex;
    flex-direction: column;
}

.display { margin-bottom: 15px; }
#result { width: 100%; height: 60px; font-size: 28px; text-align: right; padding: 10px; box-sizing: border-box; border: none; border-radius: 5px; background-color: var(--display-bg); color: var(--text-color); }

.controls { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 15px; }
.controls .btn { background-color: var(--button-ctrl-bg); }
.controls .btn:hover { filter: brightness(1.2); }

.calculator-grid { display: flex; gap: 15px; flex: 1; }
.functions-area { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; flex: 2; }
.main-pad { display: flex; gap: 10px; flex: 2; }
.basic-area { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; flex: 3; }
.operators-area { display: grid; grid-template-columns: 1fr; gap: 10px; flex: 1; }

.btn { padding: 15px 10px; font-size: 16px; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.2s; color: white; }
.num { background-color: var(--button-num-bg); }
.op { background-color: var(--button-op-bg); }
.fn { background-color: var(--button-fn-bg); }
.num:hover, .op:hover, .fn:hover { filter: brightness(1.2); }
.equals { background-color: #5cb85c; height: 100%; }
.equals:hover { filter: brightness(1.2); }

/* History Panel */
.history-panel {
    width: 250px;
    background-color: var(--panel-bg);
    color: var(--panel-text-color);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s, color 0.3s;
    display: flex;
    flex-direction: column;
}

.history-panel h3 { margin-top: 0; text-align: center; }
#history-list { list-style: none; padding: 0; margin: 0 0 20px 0; flex: 1; overflow-y: auto; border-top: 1px solid #ccc; border-bottom: 1px solid #ccc; }
#history-list li { padding: 10px; border-bottom: 1px solid #eee; font-size: 14px; word-wrap: break-word; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: background-color 0.2s; }
#history-list li:hover { background-color: rgba(0, 0, 0, 0.05); }
body.dark-mode #history-list li { border-bottom: 1px solid #444; }
body.dark-mode #history-list li:hover { background-color: rgba(255, 255, 255, 0.05); }
.history-del-btn { color: #d9534f; font-weight: bold; font-size: 12px; padding: 4px; border-radius: 4px; transition: background-color 0.2s; }
.history-del-btn:hover { background-color: rgba(217, 83, 79, 0.2); }
#clear-history { width: 100%; padding: 10px; font-size: 16px; background-color: #d9534f; color: white; border: none; border-radius: 5px; cursor: pointer; margin-top: auto;}
#clear-history:hover { filter: brightness(1.2); }

/* Handwriting Area */
.handwriting-area { display: flex; flex-direction: column; background-color: #222; padding: 10px; border-radius: 5px; flex: 1.5; }
.handwriting-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; margin-bottom: 10px; color: white; }
.handwriting-header h4 { margin: 0; }
.toggle-arrow { transition: transform 0.3s; }
.handwriting-area.collapsed .toggle-arrow { transform: rotate(-90deg); }
.handwriting-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; transition: max-height 0.3s ease-in-out, opacity 0.3s; max-height: 500px; opacity: 1; align-items: center; }
.handwriting-area.collapsed .handwriting-content { max-height: 0; opacity: 0; margin-bottom: 0; }
.handwriting-content small { color: #ccc; margin-top: 5px; }
#handwriting-canvas { border: 1px solid #555; background-color: black; cursor: crosshair; display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; border-radius: 5px; }

/* --- Graphing Calculator --- */
.graphing-container { display: flex; flex-direction: column; gap: 20px; }
.graphing-inputs { display: flex; flex-direction: column; gap: 15px; }
.graphing-inputs h3 { margin: 0; }
.func-input-group { display: flex; align-items: center; gap: 10px; }
.func-input-group span { font-size: 20px; font-weight: bold; font-family: monospace; }
#func-input { flex: 1; padding: 12px; font-size: 18px; border: 1px solid #ccc; border-radius: 5px; background-color: var(--display-bg); color: var(--text-color); }
.graphing-settings { display: flex; gap: 20px; align-items: center; }
.graphing-settings input { width: 80px; padding: 8px; border: 1px solid #ccc; border-radius: 5px; background-color: var(--display-bg); color: var(--text-color); }
.graph-area { width: 100%; height: 450px; background-color: white; border-radius: 10px; padding: 10px; box-sizing: border-box; border: 1px solid #ddd; }


/* --- 3. Spell Checker & Char Counter Menu --- */
.spell-checker-container {
    background-color: var(--panel-bg);
    color: var(--panel-text-color);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
}

.spell-checker-container h2 { margin-top: 0; margin-bottom: 20px; }

.spell-checker-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#run-spell-check {
    flex: 1;
    font-size: 18px;
    font-weight: bold;
}

#clear-spell-checker {
    padding: 10px 20px;
}

#spell-checker-textarea {
    width: 100%;
    height: 250px;
    padding: 15px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: var(--display-bg);
    color: var(--text-color);
    box-sizing: border-box;
    resize: vertical;
    margin-bottom: 20px;
}

.char-counter-results {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    background-color: var(--display-bg);
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.result-item {
    flex: 1;
    min-width: 120px;
    font-size: 16px;
}

.result-item span {
    font-weight: bold;
    color: #3e95cd;
}

/* Spell Check Results UI */
.spell-check-results {
    background-color: #fcf8e3;
    border: 1px solid #faebcc;
    border-radius: 5px;
    padding: 20px;
    margin-top: 20px;
}
body.dark-mode .spell-check-results {
    background-color: #3d3d29;
    border-color: #555533;
}

.spell-check-results h3 {
    margin-top: 0;
    color: #8a6d3b;
}
body.dark-mode .spell-check-results h3 {
    color: #e0c691;
}

#spell-check-feedback {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.spell-error-item {
    background-color: rgba(255,255,255,0.5);
    padding: 10px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 15px;
}
body.dark-mode .spell-error-item {
    background-color: rgba(0,0,0,0.2);
}

.wrong-word {
    color: #d9534f;
    font-weight: bold;
    text-decoration: line-through;
}

.arrow {
    color: #888;
}

.correct-word {
    color: #5cb85c;
    font-weight: bold;
}
.apply-fix-btn {
    margin-left: auto;
    padding: 5px 10px;
    font-size: 12px;
}

.spell-notice {
    font-size: 12px;
    opacity: 0.7;
    margin: 0;
}
.spell-notice a {
    color: #3e95cd;
    text-decoration: none;
}
.spell-notice a:hover {
    text-decoration: underline;
}

/* --- Alarm Section --- */
.alarm-section {
    max-width: 800px;
    margin: 20px auto 0;
    background: var(--panel-bg);
    color: var(--panel-text-color);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

.alarm-section h4 {
    margin: 0 0 15px 0;
    font-size: 1.05rem;
    opacity: 0.75;
}

.alarm-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

#alarm-time-input {
    padding: 12px 16px;
    font-size: 1.3rem;
    border-radius: 8px;
    border: 1px solid #ccc;
    background-color: var(--display-bg);
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
}

#alarm-status {
    margin-top: 12px;
    font-size: 0.95rem;
    min-height: 1.4em;
}

/* --- Alarm Toast Popup --- */
.alarm-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px 25px;
    border-radius: 14px;
    background: #2c2c2c;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    min-width: 280px;
    transform: translateY(140px);
    opacity: 0;
    transition: transform 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    pointer-events: none;
}

.alarm-toast.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

.alarm-toast-warning { border-left: 5px solid #f0ad4e; }
.alarm-toast-fired   { border-left: 5px solid #5cb85c; animation: toast-pulse 1s ease-in-out 3; }

@keyframes toast-pulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); }
    50%       { box-shadow: 0 8px 40px rgba(92, 184, 92, 0.6); }
}

.alarm-toast-icon { font-size: 2rem; flex-shrink: 0; }
.alarm-toast-body { flex: 1; }
.alarm-toast-title { font-size: 1.1rem; font-weight: bold; }
.alarm-toast-time  { font-size: 1.5rem; font-family: 'Courier New', monospace; margin-top: 4px; opacity: 0.9; }

.alarm-toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    align-self: flex-start;
    transition: color 0.2s;
}
.alarm-toast-close:hover { color: white; }


/* --- 3. File Converter --- */
.file-converter-container {
    background-color: var(--panel-bg);
    color: var(--panel-text-color);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
}

.file-converter-container h2 { margin-top: 0; margin-bottom: 20px; }

.conv-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--tab-bg);
    padding-bottom: 0;
}

.conv-tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 10px 20px;
    font-size: 15px;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.6;
    transition: opacity 0.2s, border-color 0.2s;
    margin-bottom: -2px;
}

.conv-tab-btn:hover { opacity: 0.9; }
.conv-tab-btn.active { opacity: 1; font-weight: bold; border-bottom-color: var(--button-fn-bg); }

.conv-panel { display: none; }
.conv-panel.active { display: block; }

.drop-zone {
    border: 2px dashed #aaa;
    border-radius: 10px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    margin-bottom: 20px;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--button-fn-bg);
    background-color: rgba(91, 192, 222, 0.07);
}

.drop-zone-icon { font-size: 2.5rem; margin-bottom: 10px; }
.drop-zone p { margin: 0 0 6px 0; font-size: 16px; }
.drop-zone small { opacity: 0.6; font-size: 13px; }

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--display-bg);
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    flex-wrap: wrap;
}

.file-badge { font-size: 1.2rem; }

.detected-badge {
    margin-left: auto;
    background-color: var(--button-fn-bg);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 13px;
}

.conv-options {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.option-row label { font-size: 14px; min-width: 70px; opacity: 0.8; }

.format-btns { display: flex; gap: 8px; }

.format-btn {
    padding: 7px 18px;
    font-size: 14px;
    border: 2px solid #aaa;
    border-radius: 20px;
    background: none;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
}

.format-btn:hover { border-color: var(--button-fn-bg); color: var(--button-fn-bg); }
.format-btn.active { border-color: var(--button-fn-bg); background-color: var(--button-fn-bg); color: white; }

#img-quality { width: 160px; cursor: pointer; }
#img-quality-val { min-width: 40px; font-size: 14px; }

#img-convert-btn, #data-convert-btn {
    padding: 12px 28px;
    font-size: 16px;
    margin-bottom: 24px;
}

#img-convert-btn:disabled, #data-convert-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: none;
}

.preview-label { font-size: 13px; opacity: 0.7; margin-bottom: 8px; }

#img-preview {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    border: 1px solid #ddd;
    display: block;
}

/* PDF Sub-tabs */
.pdf-sub-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.pdf-sub-btn {
    padding: 8px 18px;
    font-size: 14px;
    border: 2px solid #aaa;
    border-radius: 20px;
    background: none;
    color: var(--text-color);
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s;
}

.pdf-sub-btn:hover { opacity: 0.9; }
.pdf-sub-btn.active {
    background-color: var(--button-fn-bg);
    border-color: var(--button-fn-bg);
    color: white;
    opacity: 1;
    font-weight: bold;
}

.pdf-sub-panel { display: none; }
.pdf-sub-panel.active { display: block; }

/* 이미지 → PDF 썸네일 목록 */
.img-thumb-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px;
    background-color: var(--display-bg);
    border-radius: 8px;
}

.img-thumb-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 90px;
}

.img-thumb-item img {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ccc;
}

.thumb-name {
    font-size: 11px;
    opacity: 0.7;
    width: 84px;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.thumb-del-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background-color: #d9534f;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.thumb-del-btn:hover { filter: brightness(1.2); }

/* PDF → 이미지 진행 바 */
.pdf-prog-bar {
    width: 100%;
    height: 8px;
    background-color: var(--display-bg);
    border-radius: 4px;
    overflow: hidden;
}

#pdf2img-prog-fill {
    height: 100%;
    width: 0%;
    background-color: var(--button-fn-bg);
    border-radius: 4px;
    transition: width 0.3s ease;
}

#data-preview {
    background-color: var(--display-bg);
    color: var(--text-color);
    padding: 15px;
    border-radius: 8px;
    font-size: 13px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
    margin: 0;
    border: 1px solid #ddd;
}


/* ==============================================
   Mobile Header & Hamburger
   ============================================== */
.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 201;
    height: 56px;
    background-color: var(--gnb-bg);
    color: var(--gnb-text);
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    flex-shrink: 0;
}

.mobile-title {
    font-size: 20px;
    font-weight: bold;
    color: var(--gnb-active);
    flex: 1;
}

.hamburger-btn {
    background: none;
    border: none;
    color: var(--gnb-text);
    font-size: 24px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    line-height: 1;
    transition: background-color 0.2s;
}
.hamburger-btn:hover { background-color: var(--gnb-hover); }

.gnb-close-btn {
    display: none;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s;
    margin-left: auto;
    flex-shrink: 0;
}
.gnb-close-btn:hover { color: white; }

.gnb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
    cursor: pointer;
}
.gnb-overlay.visible { display: block; }


/* ==============================================
   Responsive: Tablet & Mobile (≤ 900px)
   ============================================== */
@media (max-width: 900px) {
    body {
        display: block;
        height: auto;
        overflow: auto;
    }

    .page-wrapper {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    .mobile-header { display: flex; }

    /* GNB becomes slide-out overlay */
    .gnb {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        max-width: 85vw;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    .gnb.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }

    .gnb-close-btn { display: block; }

    .gnb-header {
        display: flex;
        align-items: center;
        text-align: left;
    }
    .gnb-header h1 { flex: 1; }

    /* Content area */
    .content-area {
        padding: 16px;
        overflow-y: visible;
    }

    .main-menu-content { max-width: 100%; }

    /* ---- Server Time ---- */
    .server-time-container {
        padding: 20px;
        max-width: 100%;
    }

    .large-time-display { font-size: 2.2rem; }

    .url-input-group { flex-direction: column; }

    .alarm-section {
        max-width: 100%;
        padding: 20px;
        margin-left: 0;
        margin-right: 0;
    }

    .alarm-input-row { flex-wrap: wrap; }

    /* ---- Calculator ---- */
    .tabs { flex-wrap: wrap; }

    .main-container {
        flex-direction: column;
        height: auto;
    }

    .calculator {
        width: 100%;
        box-sizing: border-box;
    }

    .calculator-grid { flex-direction: column; }

    .functions-area {
        grid-template-columns: repeat(5, 1fr);
        flex: none;
    }

    .main-pad { flex: none; }

    .handwriting-area { flex: none; }

    .history-panel {
        width: 100%;
        max-height: 280px;
        box-sizing: border-box;
    }

    .btn { padding: 12px 8px; font-size: 14px; }

    /* ---- Graphing Calculator ---- */
    .func-input-group { flex-wrap: wrap; }
    .graphing-settings { flex-wrap: wrap; }
    .graph-area { height: 300px; }

    /* ---- File Converter ---- */
    .conv-tabs { flex-wrap: wrap; }
    .conv-tab-btn { padding: 8px 12px; font-size: 13px; }
    .option-row { flex-wrap: wrap; }
    .format-btns { flex-wrap: wrap; }

    /* ---- Alarm Toast ---- */
    .alarm-toast {
        bottom: 16px;
        right: 16px;
        left: 16px;
        min-width: unset;
    }
}
