:root {
      --bg: #070d18;
      --bg-2: #0d1728;
      --panel: rgba(15, 22, 35, 0.82);
      --panel-soft: rgba(19, 28, 43, 0.9);
      --primary: #7bd7ff;
      --secondary: #8b7dff;
      --accent: #77f0c8;
      --gold: #f4d78b;
      --rose: #ff8ebd;
      --text: #edf8ff;
      --muted: #a9bdd5;
      --danger: #ff6f88;
      --warning: #ffc772;
      --success: #5fe0a6;
      --shadow: 0 30px 80px rgba(3, 9, 22, 0.72);
      --radius: 26px;
      --glass: rgba(255,255,255,0.06);
      --brand-glow: rgba(123, 215, 255, 0.38);
      --line: rgba(183, 214, 255, 0.12);
    }

    body.light-mode {
      --bg: #edf4ff;
      --bg-2: #f8fbff;
      --panel: rgba(255, 255, 255, 0.78);
      --panel-soft: rgba(255, 255, 255, 0.92);
      --primary: #2169df;
      --secondary: #6a5cf6;
      --accent: #1bbf92;
      --gold: #d7901f;
      --rose: #ef5e9c;
      --text: #15263d;
      --muted: #59708f;
      --danger: #e7516d;
      --warning: #d98a24;
      --success: #1aa874;
      --shadow: 0 26px 60px rgba(32, 58, 98, 0.14);
      --glass: rgba(255,255,255,0.78);
      --brand-glow: rgba(33, 105, 223, 0.18);
      --line: rgba(109, 136, 182, 0.12);
    }

    * { box-sizing: border-box; }

    html, body {
      margin: 0;
      min-height: 100%;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      background:
        radial-gradient(circle at 15% 12%, rgba(123, 215, 255, 0.18), transparent 18%),
        radial-gradient(circle at 82% 16%, rgba(139, 125, 255, 0.18), transparent 26%),
        radial-gradient(circle at 52% 88%, rgba(255, 143, 189, 0.14), transparent 24%),
        linear-gradient(135deg, #040b14 0%, #0a1220 26%, #0d1828 58%, #0a1320 100%);
      color: var(--text);
      transition: background 0.25s ease, color 0.25s ease;
    }

    body.light-mode {
      background:
        radial-gradient(circle at 12% 12%, rgba(33, 105, 223, 0.10), transparent 18%),
        radial-gradient(circle at 80% 18%, rgba(106, 92, 246, 0.11), transparent 26%),
        radial-gradient(circle at 50% 80%, rgba(239, 94, 156, 0.08), transparent 22%),
        linear-gradient(135deg, #f4f8ff 0%, #edf4ff 34%, #eef2ff 100%);
    }

    body {
      display: flex;
      justify-content: center;
      align-items: flex-start;
      min-height: 100vh;
      padding: 8px;
    }

    .calc-app {
      width: 100%;
      max-width: 700px;
      background: linear-gradient(180deg, rgba(15, 22, 35, 0.82), rgba(9, 14, 24, 0.94));
      border: 1px solid rgba(123, 215, 255, 0.18);
      border-radius: 22px;
      box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.08);
      padding: 12px;
      backdrop-filter: blur(18px);
      position: relative;
      overflow: hidden;
    }

    body.light-mode .calc-app {
      background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(245,249,255,0.96));
      border-color: rgba(33, 105, 223, 0.08);
    }

    .calc-app::before {
      content: "";
      position: absolute;
      inset: 0;
      background: linear-gradient(135deg, rgba(143, 227, 255, 0.07), transparent 25%, rgba(138, 125, 255, 0.08));
      pointer-events: none;
    }

    .topbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 10px;
      gap: 8px;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
      min-height: 46px;
      padding: 8px 14px 8px 10px;
      border-radius: 14px;
      background: linear-gradient(135deg, rgba(123, 215, 255, 0.12), rgba(139, 125, 255, 0.12));
      border: 1px solid rgba(123, 215, 255, 0.18);
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 26px var(--brand-glow);
    }

    .brand-mark {
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: linear-gradient(135deg, var(--gold), var(--primary), var(--secondary));
      box-shadow: 0 0 28px rgba(123, 215, 255, 0.85);
      flex-shrink: 0;
    }

    .brand-copy {
      display: flex;
      flex-direction: column;
      line-height: 1.1;
    }

    .brand-name {
      font-weight: 800;
      letter-spacing: 0.08em;
      font-size: 0.78rem;
      text-transform: uppercase;
      color: var(--primary);
      text-shadow: 0 0 18px rgba(143, 227, 255, 0.45);
    }

    .brand-tag {
      font-size: 0.6rem;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--muted);
      opacity: 0.9;
    }

    body.light-mode .brand {
      background: linear-gradient(135deg, rgba(46, 125, 233, 0.08), rgba(109, 99, 244, 0.08));
      border-color: rgba(46, 125, 233, 0.12);
    }

    body.light-mode .brand-name {
      color: var(--primary);
      text-shadow: none;
    }

    .action-bar {
      display: flex;
      gap: 6px;
      align-items: center;
      flex-shrink: 0;
    }

    .icon-btn {
      border: 1px solid rgba(255,255,255,0.08);
      background: rgba(255,255,255,0.03);
      color: var(--text);
      width: 36px;
      height: 36px;
      min-width: 36px;
      border-radius: 10px;
      font-size: 1.08rem;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      cursor: pointer;
      transition: 0.2s ease;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .icon-btn:hover {
      transform: translateY(-1px);
      border-color: rgba(120,213,255,0.35);
    }

    #fxToggle {
      width: 52px;
      min-width: 52px;
      padding: 0 4px;
      font-size: 0.68rem;
      letter-spacing: 0.02em;
      white-space: nowrap;
    }

    #themeToggle {
      width: 62px;
      min-width: 62px;
      padding: 0 6px;
      font-size: 0.9rem;
    }

    .display-panel {
      background: linear-gradient(180deg, rgba(11, 18, 31, 0.98), rgba(17, 25, 38, 0.94));
      border: 1px solid rgba(143, 227, 255, 0.1);
      border-radius: 16px;
      padding: 10px 12px 8px;
      margin-bottom: 10px;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 12px 30px rgba(0,0,0,0.18);
    }

    body.light-mode .display-panel {
      background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(239,244,255,0.96));
    }

    .history {
      min-height: 22px;
      color: var(--muted);
      font-size: 0.76rem;
      letter-spacing: 0.04em;
      text-align: right;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      margin-bottom: 8px;
    }

    .expression {
      text-align: right;
      font-size: 0.78rem;
      color: var(--muted);
      min-height: 16px;
      margin-bottom: 3px;
      padding-right: 6px;
      word-break: break-all;
    }

    .expression.is-empty {
      display: none;
    }

    body.light-mode .expression,
    body.light-mode .history,
    body.light-mode .history-item small,
    body.light-mode .history-empty {
      color: #425776;
    }

    .result {
      text-align: right;
      font-size: clamp(1.9rem, 4vw, 3.2rem);
      line-height: 1;
      font-weight: 800;
      letter-spacing: -0.05em;
      word-break: break-all;
      min-height: 48px;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      padding-right: 8px;
      background: linear-gradient(135deg, #edf7ff, #b9d8ff, #d9d2ff);
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
    }

    body.light-mode .result {
      background: linear-gradient(135deg, #1d2d45, #2e4b76, #1b2f5c);
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
    }

    .workspace {
      display: block;
    }

    .calculator-panel {
      background: linear-gradient(180deg, rgba(17, 24, 38, 0.9), rgba(11, 17, 28, 0.94));
      border: 1px solid rgba(255,255,255,0.07);
      border-radius: 16px;
      padding: 9px;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
    }

    body.light-mode .calculator-panel {
      background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(246,249,255,0.96));
    }

    .tab-row {
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
      margin-bottom: 8px;
    }

    .tab-btn {
      background: rgba(255,255,255,0.03);
      border: 1px solid rgba(255,255,255,0.05);
      color: var(--muted);
      border-radius: 10px;
      padding: 7px 10px;
      cursor: pointer;
      font-weight: 700;
      font-size: 0.98rem;
      letter-spacing: 0.02em;
      transition: 0.2s ease;
    }

    .tab-btn.active {
      background: linear-gradient(135deg, rgba(123, 215, 255, 0.18), rgba(139, 125, 255, 0.24));
      color: var(--text);
      border-color: rgba(123, 215, 255, 0.38);
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 10px 24px rgba(123, 215, 255, 0.12);
    }

    .panel-wrap {
      display: none;
    }

    .panel-wrap.active {
      display: block;
    }

