:root {
    --bg: #FBF1E6;
    --bg-glow: #F6E4CF;
    --text: #4A3B32;
    --text-soft: #8A7A6D;
    --circle: #2F8F5B;
    --circle-dark: #1F6E45;
    --circle-shadow: rgba(47, 143, 91, 0.32);
    --card-shadow: rgba(120, 90, 60, 0.12);
    --card-bg: #ffffffb0;
    --card-border: rgba(74, 59, 50, 0.10);
    --toggle-bg: #ffffffaa;
    --toggle-border: rgba(74, 59, 50, 0.12);
    --transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  [data-theme="dark"] {
    --bg: #241C17;
    --bg-glow: #362A21;
    --text: #F3E8DC;
    --text-soft: #B4A392;
    --circle: #4CAF7D;
    --circle-dark: #2E8F5C;
    --circle-shadow: rgba(76, 175, 125, 0.42);
    --card-shadow: rgba(0, 0, 0, 0.35);
    --card-bg: #ffffff0f;
    --card-border: rgba(255, 255, 255, 0.10);
    --toggle-bg: #ffffff14;
    --toggle-border: rgba(255, 255, 255, 0.14);
  }

  * { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; touch-action: manipulation; }

  body {
    font-family: 'Playpen Sans', sans-serif;
    background:
      radial-gradient(circle at 20% 15%, var(--bg-glow), transparent 55%),
      radial-gradient(circle at 85% 90%, var(--bg-glow), transparent 50%),
      var(--bg);
    background-attachment: fixed;
    background-size: cover;
    color: var(--text);
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
  }

  .page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(90px + env(safe-area-inset-top)) 20px calc(50px + env(safe-area-inset-bottom));
  }

  .wrap {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
  }

  /* ---------- top icons ---------- */
  .icon-btn {
    position: fixed;
    top: max(24px, env(safe-area-inset-top));
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--toggle-border);
    background: var(--toggle-bg);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition), transform 0.2s ease;
    z-index: 20;
  }
  .icon-btn:hover { transform: scale(1.06); }
  .icon-btn svg { width: 21px; height: 21px; stroke: var(--text); }

  #themeToggle { right: 24px; }
  #backBtn { left: 24px; }

  .icon-sun { display: none; }
  .icon-moon { display: block; }
  [data-theme="dark"] .icon-sun { display: block; }
  [data-theme="dark"] .icon-moon { display: none; }

  /* ---------- hero ---------- */
  .hero-card {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 28px;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
  }

  .hero-label {
    font-size: 13px;
    color: var(--text-soft);
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
  }

  .hero-hijri-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .hero-hijri-daynum {
    font-family: 'Noto Sans', sans-serif;
    font-weight: 800;
    font-size: clamp(32px, 8.5vw, 42px);
    line-height: 1.2;
  }

  .hero-hijri-month {
    font-family: 'Noto Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(22.4px, 5.95vw, 29.4px);
    line-height: 1.2;
  }

  .hero-hijri-year {
    font-size: 15px;
    color: var(--text-soft);
    font-weight: 600;
  }

  .hero-divider {
    width: 40px;
    height: 2px;
    border-radius: 2px;
    background: var(--card-border);
    margin: 6px 0;
  }

  .hero-gregorian {
    font-size: 16px;
    color: var(--text-soft);
  }

  .hero-weekday {
    font-family: 'Noto Sans', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--circle);
  }

  /* ---------- converter card ---------- */
  .conv-card {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .conv-title {
    font-family: 'Noto Sans', sans-serif;
    font-weight: 800;
    font-size: 20px;
  }

  .conv-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .conv-sub {
    font-size: 13px;
    color: var(--text-soft);
    line-height: 1.4;
  }

  .conv-field {
    width: 100%;
  }

  .conv-field label {
    display: block;
    font-size: 13px;
    color: var(--text-soft);
    font-weight: 600;
    margin-bottom: 8px;
  }

  .conv-field input {
    box-sizing: border-box;
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--card-border);
    background: var(--bg);
    color: var(--text);
    font-family: 'Noto Sans', sans-serif;
    font-size: 16px;
    text-align: left;
    -webkit-appearance: auto;
    appearance: auto;
    color-scheme: light;
  }
  [data-theme="dark"] .conv-field input { color-scheme: dark; }
  .conv-field input:focus { outline: 2px solid var(--circle); outline-offset: 1px; }

  .conv-result {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 18px;
    border-radius: 16px;
    background: var(--toggle-bg);
    border: 1px solid var(--card-border);
  }

  .conv-result-main {
    font-family: 'Noto Sans', sans-serif;
    font-weight: 700;
    font-size: 19px;
  }

  .conv-result-sub {
    font-size: 13px;
    color: var(--text-soft);
    line-height: 1.4;
  }

  .today-btn {
    align-self: center;
    background: none;
    border: none;
    color: var(--circle);
    font-family: 'Playpen Sans', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 12px;
  }
