/* Material Design 3 base for the calculator and the wiki (seed colour: saffron #B5481C). */
:root {
  --md-primary: #9a4521;
  --md-on-primary: #ffffff;
  --md-primary-container: #ffdbcc;
  --md-on-primary-container: #380d00;
  --md-secondary: #77574a;
  --md-secondary-container: #ffdbcc;
  --md-on-secondary-container: #2c160c;
  --md-tertiary: #695e2f;
  --md-tertiary-container: #f2e2a7;
  --md-on-tertiary-container: #221b00;
  --md-surface: #fff8f6;
  --md-surface-lowest: #ffffff;
  --md-surface-low: #fff1ec;
  --md-surface-container: #fceae4;
  --md-surface-high: #f6e5de;
  --md-surface-highest: #f0dfd8;
  --md-on-surface: #231a16;
  --md-on-surface-variant: #53433d;
  --md-outline: #85736c;
  --md-outline-variant: #d8c2ba;
  --md-error: #ba1a1a;
  --md-error-container: #ffdad6;
  --md-on-error-container: #410002;
  --md-inverse-surface: #392e2a;
  --md-inverse-on-surface: #ffede7;
  --md-inverse-primary: #ffb595;
  --md-scrim: rgba(0, 0, 0, .32);
  --md-elev-1: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px 1px rgba(0, 0, 0, .15);
  --md-elev-2: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 6px 2px rgba(0, 0, 0, .15);
  --md-elev-3: 0 4px 8px 3px rgba(0, 0, 0, .15), 0 1px 3px rgba(0, 0, 0, .3);
  --md-shape-xs: 4px;
  --md-shape-s: 8px;
  --md-shape-m: 12px;
  --md-shape-l: 16px;
  --md-shape-xl: 28px;
  --md-ease: cubic-bezier(.2, 0, 0, 1);
  --md-mono: "Roboto Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --md-primary: #ffb595; --md-on-primary: #591d00;
    --md-primary-container: #7b2e0b; --md-on-primary-container: #ffdbcc;
    --md-secondary: #e7bdad; --md-secondary-container: #5d4034; --md-on-secondary-container: #ffdbcc;
    --md-tertiary: #d5c68d; --md-tertiary-container: #50461a; --md-on-tertiary-container: #f2e2a7;
    --md-surface: #1a110e; --md-surface-lowest: #140c09; --md-surface-low: #231a16;
    --md-surface-container: #271e1a; --md-surface-high: #322824; --md-surface-highest: #3d322e;
    --md-on-surface: #f0dfd8; --md-on-surface-variant: #d8c2ba;
    --md-outline: #a08d86; --md-outline-variant: #53433d;
    --md-error: #ffb4ab; --md-error-container: #93000a; --md-on-error-container: #ffdad6;
    --md-inverse-surface: #f0dfd8; --md-inverse-on-surface: #392e2a; --md-inverse-primary: #9a4521;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --md-primary: #ffb595; --md-on-primary: #591d00;
  --md-primary-container: #7b2e0b; --md-on-primary-container: #ffdbcc;
  --md-secondary: #e7bdad; --md-secondary-container: #5d4034; --md-on-secondary-container: #ffdbcc;
  --md-tertiary: #d5c68d; --md-tertiary-container: #50461a; --md-on-tertiary-container: #f2e2a7;
  --md-surface: #1a110e; --md-surface-lowest: #140c09; --md-surface-low: #231a16;
  --md-surface-container: #271e1a; --md-surface-high: #322824; --md-surface-highest: #3d322e;
  --md-on-surface: #f0dfd8; --md-on-surface-variant: #d8c2ba;
  --md-outline: #a08d86; --md-outline-variant: #53433d;
  --md-error: #ffb4ab; --md-error-container: #93000a; --md-on-error-container: #ffdad6;
  --md-inverse-surface: #f0dfd8; --md-inverse-on-surface: #392e2a; --md-inverse-primary: #9a4521;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--md-surface);
  color: var(--md-on-surface);
  font: 400 14px/20px "Roboto", "Noto Sans Tamil", system-ui, sans-serif;
  letter-spacing: .25px;
}
[hidden] { display: none !important; }

/* ---------- type scale ---------- */
.headline-small { font-size: 24px; line-height: 32px; font-weight: 400; margin: 0; letter-spacing: 0; }
.title-large { font-size: 22px; line-height: 28px; font-weight: 400; margin: 0; letter-spacing: 0; }
.title-medium { font-size: 16px; line-height: 24px; font-weight: 500; margin: 0; letter-spacing: .15px; }
.title-small { font-size: 14px; line-height: 20px; font-weight: 500; margin: 0; letter-spacing: .1px; }
.label-large { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: .1px; }
.label-medium { font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .5px; }
.body-small { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--md-on-surface-variant); }
.mono { font-family: var(--md-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal; font-style: normal; font-size: 24px; line-height: 1;
  display: inline-block; white-space: nowrap; direction: ltr; overflow: hidden;
  -webkit-font-smoothing: antialiased; font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  user-select: none;
}

/* ---------- top app bar ---------- */
.app-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  height: 64px; padding: 0 8px 0 4px;
  background: var(--md-surface);
  transition: background .2s var(--md-ease);
}
.app-bar.scrolled { background: var(--md-surface-container); }
.app-bar-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding-left: 12px; }
.app-bar-title .title-large { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-mark {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--md-primary-container); color: var(--md-on-primary-container); font-size: 19px;
}
.app-bar-actions { display: flex; align-items: center; gap: 4px; }

/* ---------- buttons ---------- */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 24px; border-radius: 20px; border: none;
  font: 500 14px/20px "Roboto", sans-serif; letter-spacing: .1px;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: box-shadow .2s var(--md-ease);
}
.btn .material-symbols-outlined { font-size: 18px; margin-left: -8px; }
.btn::after { content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity .15s; }
.btn:hover::after { opacity: .08; }
.btn:focus-visible::after, .btn:active::after { opacity: .12; }
.btn:disabled { cursor: default; opacity: .38; }
.btn-filled { background: var(--md-primary); color: var(--md-on-primary); }
.btn-filled:hover { box-shadow: var(--md-elev-1); }
.btn-tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.btn-outlined { background: transparent; color: var(--md-primary); border: 1px solid var(--md-outline); }
.btn-text { background: transparent; color: var(--md-primary); padding: 0 12px; }
.btn-text .material-symbols-outlined { margin-left: 0; }
.icon-btn {
  position: relative; overflow: hidden;
  width: 40px; height: 40px; border-radius: 50%; border: none; flex: none;
  display: inline-grid; place-items: center;
  background: transparent; color: var(--md-on-surface-variant); cursor: pointer; text-decoration: none;
}
.icon-btn::after { content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity .15s; }
.icon-btn:hover::after { opacity: .08; }
.icon-btn:active::after { opacity: .12; }

/* ---------- cards ---------- */
.card { border-radius: var(--md-shape-m); padding: 16px; }
.card-elevated { background: var(--md-surface-low); box-shadow: var(--md-elev-1); }
.card-filled { background: var(--md-surface-highest); }
.card-outlined { background: var(--md-surface); border: 1px solid var(--md-outline-variant); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

/* ---------- outlined text fields (floating label) ---------- */
.field { position: relative; display: block; min-width: 0; }
.field input, .field select {
  width: 100%; height: 56px; padding: 18px 16px 2px;
  border: 1px solid var(--md-outline); border-radius: var(--md-shape-xs);
  background: transparent; color: var(--md-on-surface);
  font: 400 16px/24px "Roboto", sans-serif; letter-spacing: .5px;
  outline: none; appearance: none; -webkit-appearance: none;
  transition: border-color .15s;
}
.field select {
  padding-right: 44px; cursor: pointer; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--md-on-surface-variant) 50%),
                    linear-gradient(135deg, var(--md-on-surface-variant) 50%, transparent 50%);
  background-position: calc(100% - 22px) 26px, calc(100% - 17px) 26px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.field select option { background: var(--md-surface-container); color: var(--md-on-surface); }
.field > span.label {
  position: absolute; left: 12px; top: 16px; padding: 0 4px;
  color: var(--md-on-surface-variant); font-size: 16px; line-height: 24px;
  pointer-events: none; transform-origin: left top;
  transition: transform .15s var(--md-ease), color .15s;
  white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis;
}
.field input:not(:placeholder-shown) + span.label,
.field input:focus + span.label,
.field select + span.label { transform: translateY(-11px) scale(.75); }
.field input::placeholder { color: transparent; }
.field input:focus::placeholder { color: var(--md-on-surface-variant); }
.field:hover input, .field:hover select { border-color: var(--md-on-surface); }
.field input:focus, .field select:focus { border: 2px solid var(--md-primary); padding-left: 15px; }
.field input:focus + span.label, .field select:focus + span.label { color: var(--md-primary); }
.field input:user-invalid { border-color: var(--md-error); }
.field input:user-invalid + span.label { color: var(--md-error); }
.field .trailing { position: absolute; right: 12px; top: 16px; color: var(--md-on-surface-variant); pointer-events: none; }
.supporting { display: block; padding: 4px 16px 0; font-size: 12px; line-height: 16px; color: var(--md-on-surface-variant); }

/* ---------- segmented buttons ---------- */
.segmented { display: flex; height: 56px; min-width: 0; }
.segmented label {
  position: relative; flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--md-outline); margin-left: -1px; cursor: pointer;
  font-weight: 500; letter-spacing: .1px; color: var(--md-on-surface); user-select: none;
  transition: background .15s;
}
.segmented label:first-child { margin-left: 0; border-radius: 28px 0 0 28px; }
.segmented label:last-child { border-radius: 0 28px 28px 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.segmented label:has(input:checked)::before { content: "check"; font-family: "Material Symbols Outlined"; font-size: 18px; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--md-primary); outline-offset: -2px; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--md-shape-s); border: 1px solid var(--md-outline-variant);
  font: 500 14px/20px "Roboto", sans-serif; color: var(--md-on-surface-variant); background: transparent;
}
.chip .material-symbols-outlined { font-size: 18px; }
.chip-tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-color: transparent; }

/* ---------- menus ---------- */
.menu {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 8px 0; list-style: none;
  background: var(--md-surface-container); border-radius: var(--md-shape-xs);
  box-shadow: var(--md-elev-2); max-height: 320px; overflow-y: auto;
}
.menu li { display: flex; flex-direction: column; justify-content: center; min-height: 48px; padding: 6px 16px; cursor: pointer; }
.menu li span { font-size: 16px; line-height: 24px; }
.menu li small { color: var(--md-on-surface-variant); font-size: 12px; }
.menu li:hover, .menu li[aria-selected="true"] { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }

/* ---------- tabs ---------- */
.tabs {
  display: flex; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--md-outline-variant);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; flex: 1 0 auto; height: 48px; padding: 0 16px; border: none; background: transparent;
  color: var(--md-on-surface-variant); font: 500 14px/20px "Roboto", sans-serif; letter-spacing: .1px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.tab .material-symbols-outlined { font-size: 20px; }
.tab:hover { background: color-mix(in srgb, var(--md-on-surface) 6%, transparent); }
.tab[aria-selected="true"] { color: var(--md-primary); }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--md-primary);
}

/* ---------- progress & snackbar ---------- */
.linear-progress { position: relative; height: 4px; overflow: hidden; background: var(--md-secondary-container); }
.linear-progress::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%;
  background: var(--md-primary); border-radius: 2px; animation: progress 1.2s var(--md-ease) infinite;
}
@keyframes progress { to { left: 100%; } }
.snackbar {
  position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translate(-50%, 24px);
  width: max-content; max-width: min(560px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 16px; min-height: 48px;
  border-radius: var(--md-shape-xs); background: var(--md-inverse-surface); color: var(--md-inverse-on-surface);
  box-shadow: var(--md-elev-3); opacity: 0; pointer-events: none;
  transition: opacity .2s var(--md-ease), transform .2s var(--md-ease);
}
.snackbar.open { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.snackbar p { flex: 1; margin: 0; }
.snackbar .btn-text { color: var(--md-inverse-primary); }

/* ---------- label / value lists ---------- */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 24px; margin: 0; }
.kv > div { padding: 10px 0; border-bottom: 1px solid var(--md-outline-variant); min-width: 0; }
.kv dt { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--md-on-surface-variant); }
.kv dd { margin: 2px 0 0; font-size: 16px; line-height: 24px; letter-spacing: .15px; overflow-wrap: anywhere; }

/* ---------- data table ---------- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; height: 48px; padding: 0 16px; font-weight: 500; font-size: 12px; letter-spacing: .5px;
  color: var(--md-on-surface-variant); border-bottom: 1px solid var(--md-outline-variant);
}
.data-table td { height: 52px; padding: 0 16px; border-bottom: 1px solid var(--md-outline-variant); font-size: 15px; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--md-on-surface) 4%, transparent); }
.data-table tbody tr:last-child td { border-bottom: none; }

@media (max-width: 600px) {
  .app-bar { height: 56px; }
  .data-table th, .data-table td { padding: 0 8px; }
  .btn { padding: 0 20px; }
}
