* {
    transition: all 0.2s ease;
    padding: 0;
    margin: 0;
}

html, body { width: 100%; height: 100%; }

body {
    background: #1a1a2e;
    font-family: "Helvetica Neue", Helvetica, "Microsoft Yahei", "Hiragino Sans GB", "WenQuanYi Micro Hei", sans-serif;
    -webkit-font-smoothing: antialiased;
    padding-top: 20px;
    color: #333;
}

a { text-decoration: none; }
a:hover, a:focus { text-shadow: 0 1px 1px #555; }

.web-title { color: #fff; margin: 20px 0 20px 0; }
.web-title h1 { font-size: 26px; margin: 0; }
.web-title p { font-size: 13px; color: #a0a0c0; margin-top: 4px; }

@media (min-width: 770px) { .navbar-brand { display: none; } }
@media (max-width: 770px) {
    .web-title { display: none; }
    .nav-main { padding: 0; }
}

/* Calculator Panel */
.calc-panel {
    background: #16213e;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    margin-top: 10px;
}

.display-area {
    background: #0f3460;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    min-height: 100px;
}

#exprDisplay {
    color: #a0c4ff;
    font-size: 18px;
    font-family: "Courier New", monospace;
    min-height: 28px;
    word-break: break-all;
    line-height: 1.5;
}

#resultDisplay {
    color: #e8d44d;
    font-size: 32px;
    font-weight: 700;
    font-family: "Courier New", monospace;
    min-height: 42px;
    word-break: break-all;
}

#errorDisplay {
    color: #ff6b6b;
    font-size: 14px;
    display: none;
    margin-top: 5px;
}

.angle-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.angle-bar .btn {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 4px;
}
.angle-bar .btn.active {
    background: #e94560;
    border-color: #e94560;
    color: #fff;
}
.angle-bar .btn:not(.active) {
    background: #1a1a3e;
    border-color: #2a2a5e;
    color: #8a8ab0;
}

.mem-indicator {
    color: #e94560;
    font-weight: 700;
    font-size: 13px;
    padding: 2px 8px;
    background: #1a1a3e;
    border-radius: 4px;
    display: inline-block;
    min-width: 24px;
    text-align: center;
}
.mem-indicator.has-mem { background: #e94560; color: #fff; }

/* Button Grid */
.btn-grid {
    display: grid;
    gap: 6px;
}

.btn-grid .btn {
    font-size: 15px;
    font-weight: 600;
    padding: 12px 0;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    user-select: none;
}

.btn-grid .btn-num {
    background: #1a1a3e;
    color: #fff;
}
.btn-grid .btn-num:hover { background: #2a2a5e; }

.btn-grid .btn-op {
    background: #0f3460;
    color: #e8d44d;
}
.btn-grid .btn-op:hover { background: #1a4a8a; }

.btn-grid .btn-fn {
    background: #16213e;
    color: #53d8fb;
    font-size: 13px;
}
.btn-grid .btn-fn:hover { background: #1e2d5e; }
.btn-grid .btn-fn .fn-sub { font-size: 10px; color: #8a8ab0; display: block; }

.btn-grid .btn-eq {
    background: #e94560;
    color: #fff;
    font-size: 20px;
}
.btn-grid .btn-eq:hover { background: #c73650; }

.btn-grid .btn-clear {
    background: #533483;
    color: #fff;
}
.btn-grid .btn-clear:hover { background: #6a44a8; }

.btn-grid .btn-2nd {
    background: #533483;
    color: #e8d44d;
}
.btn-grid .btn-2nd.active { background: #e8d44d; color: #1a1a2e; }

.btn-grid .btn-mem {
    background: #1a1a3e;
    color: #f5a623;
    font-size: 12px;
}
.btn-grid .btn-mem:hover { background: #2a2a5e; }

.btn-grid .btn-const {
    background: #16213e;
    color: #6c5ce7;
}
.btn-grid .btn-const:hover { background: #1e2d5e; }

.btn-grid .fn-label {
    display: block;
    line-height: 1.2;
}

/* Layout grid */
.calc-layout {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 15px;
}

@media (max-width: 768px) {
    .calc-layout { grid-template-columns: 1fr; }
    .side-panel { order: -1; }
}

.side-panel .nav-tabs {
    border-bottom: none;
}
.side-panel .nav-tabs > li > a {
    color: #8a8ab0;
    font-size: 12px;
    padding: 6px 8px;
    border: none;
    background: transparent;
}
.side-panel .nav-tabs > li.active > a,
.side-panel .nav-tabs > li.active > a:hover,
.side-panel .nav-tabs > li.active > a:focus {
    background: #0f3460;
    color: #fff;
    border: none;
    border-radius: 4px;
}
.side-panel .nav-tabs > li > a:hover {
    background: #1a1a3e;
    border: none;
    border-radius: 4px;
}

.side-panel .tab-content {
    background: #0f3460;
    border-radius: 0 0 8px 8px;
    padding: 12px;
    min-height: 300px;
    max-height: 420px;
    overflow-y: auto;
}

.history-item {
    padding: 8px 10px;
    border-bottom: 1px solid #1a1a3e;
    cursor: pointer;
    border-radius: 4px;
}
.history-item:hover { background: #1a1a3e; }
.history-item .history-expr { color: #a0c4ff; font-size: 13px; font-family: monospace; }
.history-item .history-result { color: #e8d44d; font-size: 16px; font-weight: 700; font-family: monospace; }
.history-item .history-time { color: #666; font-size: 11px; }

.history-actions { margin-bottom: 8px; }
.history-actions .btn { font-size: 11px; padding: 3px 8px; }

/* Base Conversion */
.base-row { margin-bottom: 8px; }
.base-row label { color: #a0c4ff; font-size: 12px; font-weight: 600; display: block; margin-bottom: 2px; }
.base-row input { background: #1a1a3e; border: 1px solid #2a2a5e; color: #fff; padding: 6px 10px; border-radius: 4px; width: 100%; font-family: monospace; font-size: 13px; }
.base-row input:focus { border-color: #e94560; outline: none; }
#baseWarning { color: #ff6b6b; font-size: 12px; display: none; margin-top: 4px; }

/* Statistics */
#statsInput { background: #1a1a3e; border: 1px solid #2a2a5e; color: #fff; width: 100%; min-height: 60px; padding: 8px; border-radius: 4px; font-family: monospace; font-size: 13px; resize: vertical; }
#statsInput:focus { border-color: #e94560; outline: none; }
.stats-table { margin-bottom: 0; }
.stats-table td { padding: 4px 8px !important; font-size: 12px; color: #ccc; border-color: #1a1a3e !important; }
.stats-table td:nth-child(2n) { color: #e8d44d; font-weight: 700; text-align: right; }
.side-panel .btn-calc-sm { background: #e94560; color: #fff; font-size: 12px; padding: 4px 12px; border: none; border-radius: 4px; margin-top: 6px; }

/* Equations */
.eqn-fields { display: none; }
.eqn-fields.active { display: block; }
.eqn-row { margin-bottom: 6px; }
.eqn-row label { color: #a0c4ff; font-size: 12px; display: inline-block; width: 20px; }
.eqn-row input { background: #1a1a3e; border: 1px solid #2a2a5e; color: #fff; padding: 4px 8px; border-radius: 4px; width: 70px; font-family: monospace; font-size: 13px; }
.eqn-row input:focus { border-color: #e94560; outline: none; }
#eqnResult { color: #e8d44d; font-size: 14px; font-weight: 700; margin-top: 8px; font-family: monospace; word-break: break-all; }
.eqn-tabs { margin-bottom: 8px; }
.eqn-tab-btn { font-size: 11px; padding: 3px 8px; background: #1a1a3e; border: none; color: #8a8ab0; border-radius: 4px; margin-right: 4px; }
.eqn-tab-btn.active { background: #e94560; color: #fff; }

/* Unit Conversion */
.unit-row { margin-bottom: 6px; }
.unit-row label { color: #a0c4ff; font-size: 12px; display: block; margin-bottom: 2px; }
.unit-row select, .unit-row input { background: #1a1a3e; border: 1px solid #2a2a5e; color: #fff; padding: 4px 8px; border-radius: 4px; width: 100%; font-size: 12px; }
.unit-row select:focus, .unit-row input:focus { border-color: #e94560; outline: none; }
#unitResult { color: #e8d44d; font-size: 14px; font-weight: 700; margin-top: 6px; font-family: monospace; }

/* Constants Panel */
.const-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.const-btn { background: #1a1a3e; border: 1px solid #2a2a5e; color: #6c5ce7; padding: 6px; border-radius: 4px; font-size: 13px; cursor: pointer; text-align: center; font-family: monospace; }
.const-btn:hover { background: #2a2a5e; border-color: #6c5ce7; }
.const-btn .const-val { display: block; font-size: 10px; color: #666; }

/* Description Section */
.desc-section {
    background: #fff;
    border-radius: 8px;
    padding: 25px;
    margin-top: 20px;
}
.desc-section h3 {
    font-size: 18px;
    color: #1a1a2e;
    margin: 25px 0 12px;
    border-left: 4px solid #1a1a2e;
    padding-left: 12px;
}
.desc-section h3:first-child { margin-top: 0; }
.desc-section h4 {
    font-size: 15px;
    color: #333;
    margin: 15px 0 8px;
}
.desc-section p, .desc-section li {
    font-size: 14px;
    line-height: 1.9;
    color: #555;
}
.desc-section ul, .desc-section ol { padding-left: 22px; }
.desc-section li { margin-bottom: 5px; }
.desc-section blockquote {
    border-left: 3px solid #1a1a2e;
    padding: 10px 18px;
    margin: 12px 0;
    background: #f8f9fa;
    font-size: 14px;
    color: #666;
    line-height: 1.8;
    font-family: "Courier New", monospace;
}
.desc-section .alert-info {
    background: #f0f4f8;
    border-color: #1a1a2e;
    color: #1a1a2e;
    font-size: 14px;
    border-radius: 4px;
}
.desc-section table { width: 100%; margin: 10px 0; }
.desc-section table th, .desc-section table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    font-size: 13px;
}
.desc-section table th { background: #f5f5f5; font-weight: 700; }

.code-block {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    font-family: "Courier New", monospace;
    font-size: 13px;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre;
    color: #333;
    margin: 10px 0;
}

.use-case-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin: 10px 0;
}
.use-case-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
}
.use-case-card .uc-icon { font-size: 24px; margin-bottom: 6px; }
.use-case-card h5 { font-size: 14px; font-weight: 700; color: #1a1a2e; margin: 0 0 6px; }
.use-case-card p { font-size: 13px; color: #666; line-height: 1.7; margin: 0; }

.compare-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.compare-table th, .compare-table td { border: 1px solid #ddd; padding: 8px 12px; font-size: 13px; text-align: left; }
.compare-table th { background: #1a1a2e; color: #fff; font-weight: 600; }
.compare-table td { color: #555; }
.compare-table tr:nth-child(even) { background: #f8f9fa; }
.compare-table .compare-highlight { background: #e8f4e8 !important; }
.compare-table td:first-child { font-weight: 600; color: #333; }

@media (max-width: 480px) {
    .calc-panel { padding: 12px; }
    #resultDisplay { font-size: 24px; }
    .btn-grid .btn { font-size: 13px; padding: 10px 0; }
    .desc-section { padding: 15px; }
    .use-case-grid { grid-template-columns: 1fr; }
}

.text-muted { color: #666 !important; }
.mt-10 { margin-top: 10px; }
.mb-10 { margin-bottom: 10px; }
