/* CinderCalc on the web: the Android app's Material 3 look, in plain CSS. Colors are variables that
   js/theme.js sets from the chosen palette; these defaults are the Rose palette. */

:root {
  --primary: #a43655;
  --on-primary: #ffffff;
  --primary-container: #ffd9df;
  --on-primary-container: #3f0017;
  --secondary-container: #ffd9df;
  --on-secondary-container: #301219;
  --tertiary: #77583a;
  --tertiary-container: #ffdcbf;
  --on-tertiary-container: #2a1800;
  --error: #ba1829;
  --surface: #fff8f9;
  --on-surface: #22191b;
  --on-surface-variant: #574145;
  --outline: #897175;
  --outline-variant: #dac0c4;
  --inverse-surface: #382e2f;
  --inverse-on-surface: #fbedef;
  --surface-container-low: #fef0f2;
  --surface-container: #f8ebed;
  --surface-container-high: #f3e5e7;
  --surface-container-highest: #eddfe1;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #ffb1c0;
    --on-primary: #660029;
    --primary-container: #87193e;
    --on-primary-container: #ffd9df;
    --secondary-container: #5f3d44;
    --on-secondary-container: #ffd9df;
    --tertiary: #e6bf9d;
    --tertiary-container: #5e4124;
    --on-tertiary-container: #ffdcbf;
    --error: #ffb4ab;
    --surface: #1b1112;
    --on-surface: #eddfe1;
    --on-surface-variant: #dac0c4;
    --outline: #a38b8e;
    --outline-variant: #574145;
    --inverse-surface: #eddfe1;
    --inverse-on-surface: #382e2f;
    --surface-container-low: #22191b;
    --surface-container: #271d1f;
    --surface-container-high: #312729;
    --surface-container-highest: #3c3234;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--surface); color: var(--on-surface); font-size: 16px; line-height: 1.4; }
button, input { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; margin: 0; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
a { color: var(--primary); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 24px; height: 24px; fill: currentColor; flex: none; }

/* A pressed or hovered button gets a translucent layer of its text color, as in Material. */
.field-main, .text-button, .icon-button, .tonal-icon-button, .segment, .key, .currency-button,
.currency-row, .swatch, .nav button .pill, .swap { position: relative; isolation: isolate; }
:is(.field-main, .text-button, .icon-button, .tonal-icon-button, .segment, .key, .currency-button,
.currency-row, .swatch, .nav button .pill, .swap)::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: currentColor;
  opacity: 0; transition: opacity .15s; pointer-events: none; z-index: -1;
}
@media (hover: hover) {
  :is(.field-main, .text-button, .icon-button, .tonal-icon-button, .segment, .key, .currency-button,
  .currency-row, .swatch, .swap):hover:not(:disabled)::after,
  .nav button:hover .pill::after { opacity: .08; }
}
:is(.field-main, .text-button, .icon-button, .tonal-icon-button, .segment, .key, .currency-button,
.currency-row, .swatch, .swap):active:not(:disabled)::after,
.nav button:active .pill::after { opacity: .12; }

/* ------------------------------------------------------------------ app shell */

.app {
  display: grid;
  grid-template: "bar" auto "main" 1fr "nav" auto / minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
}
.top-bar {
  grid-area: bar; display: flex; align-items: center; gap: 8px; min-height: 64px;
  padding: env(safe-area-inset-top) calc(8px + env(safe-area-inset-right)) 0 calc(24px + env(safe-area-inset-left));
}
.top-bar h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 400; }
.spinner-slot { width: 48px; height: 48px; display: grid; place-items: center; }
.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--primary) 25%, transparent); border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { rotate: 360deg; } }
main { grid-area: main; overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.noscript { padding: 24px; }
.screen {
  display: flex; flex-direction: column; gap: 16px; min-height: 100%;
  padding: 8px calc(16px + env(safe-area-inset-right)) 24px calc(16px + env(safe-area-inset-left));
}
.nav {
  grid-area: nav; display: flex; background: var(--surface-container);
  padding: 12px calc(8px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
}
.nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; color: var(--on-surface-variant);
}
.nav .pill { width: 64px; height: 32px; border-radius: 16px; display: grid; place-items: center; transition: background-color .2s; }
.nav .pill .icon { grid-area: 1 / 1; }
.nav .icon.on, .nav button[aria-current="page"] .icon.off { display: none; }
.nav button[aria-current="page"] .icon.on { display: block; }
.nav button[aria-current="page"] { color: var(--on-surface); }
.nav button[aria-current="page"] .pill { background: var(--secondary-container); color: var(--on-secondary-container); }

/* A phone on its side is short: the tabs move to a rail on the left. */
@media (orientation: landscape) and (max-height: 540px) {
  .app { grid-template: "nav bar" auto "nav main" 1fr / auto minmax(0, 1fr); max-width: none; }
  .nav { flex-direction: column; justify-content: center; gap: 12px; padding: 12px 8px 12px calc(8px + env(safe-area-inset-left)); }
  .nav button { flex: none; width: 80px; }
  .top-bar { padding-left: 24px; }
  .screen { padding-left: 16px; }
}

/* ------------------------------------------------------------------ shared parts */

.segmented { display: flex; border: 1px solid var(--outline); border-radius: 20px; overflow: hidden; min-height: 40px; }
.segment {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0;
  padding: 0 12px; font-size: 14px; font-weight: 500; color: var(--on-surface);
}
.segment + .segment { border-left: 1px solid var(--outline); }
.segment .check { width: 18px; height: 18px; display: none; }
.segment.selected { background: var(--secondary-container); color: var(--on-secondary-container); }
.segment.selected .check { display: block; }
.segment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.panel { display: flex; flex-direction: column; gap: 16px; }
.no-check .segment .check { display: none; }
.no-check .segment { padding: 0 4px; }
.direction { display: flex; align-items: center; gap: 8px; }
.direction .segmented { flex: 1; }

.icon-button { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--on-surface-variant); }
.icon-button:disabled { color: color-mix(in srgb, var(--on-surface) 38%, transparent); }
.result .icon-button { color: inherit; }
.text-button { padding: 10px 12px; border-radius: 20px; color: var(--primary); font-size: 14px; font-weight: 500; flex: none; }
.text-button:disabled { color: color-mix(in srgb, currentColor 38%, transparent); }
.tonal-button {
  padding: 10px 24px; border-radius: 20px; background: var(--secondary-container); color: var(--on-secondary-container);
  font-size: 14px; font-weight: 500; flex: none;
}

.field { position: relative; display: flex; align-items: center; background: var(--surface-container); border-radius: 28px; min-height: 72px; padding-right: 8px; }
.field-main { flex: 1; display: flex; align-items: center; gap: 16px; min-width: 0; padding: 12px 8px 12px 20px; border-radius: 28px; text-align: left; }
.field-icon { color: var(--primary); }
.field-text { display: flex; flex-direction: column; min-width: 0; }
.field-label { font-size: 12px; font-weight: 500; color: var(--on-surface-variant); }
.field-value { font-size: 16px; font-weight: 500; }
.picker-input { position: absolute; left: 20px; bottom: 6px; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; pointer-events: none; }
.badge {
  flex: none; margin-right: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--primary-container); color: var(--on-primary-container); font-size: 14px; font-weight: 500;
}

.steps-and-result { display: flex; flex-direction: column; gap: 16px; scroll-margin: 16px; }
.steppers { display: flex; background: var(--surface-container); border-radius: 28px; padding: 12px 4px; }
.stepper { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.stepper-label { font-size: 14px; font-weight: 500; color: var(--on-surface-variant); }
.tonal-icon-button {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--secondary-container); color: var(--on-secondary-container);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tonal-icon-button:disabled { background: color-mix(in srgb, var(--on-surface) 12%, transparent); color: color-mix(in srgb, var(--on-surface) 38%, transparent); }
.number {
  width: 76px; max-width: 100%; border: 0; border-radius: 12px; padding: 8px 4px;
  background: var(--surface-container-highest); text-align: center; font-size: 22px; caret-color: var(--primary);
}
.number::placeholder { color: var(--on-surface-variant); opacity: .5; }

.result { background: var(--primary-container); color: var(--on-primary-container); border-radius: 28px; padding: 18px 8px 8px 20px; }
.result-label { font-size: 14px; font-weight: 500; padding-right: 12px; }
.result-headline { font-size: 24px; font-weight: 600; line-height: 1.3; margin-top: 4px; padding-right: 12px; overflow-wrap: anywhere; }
.result-details { display: grid; gap: 4px; margin-top: 4px; padding-right: 12px; font-size: 14px; }
.result-actions { display: flex; justify-content: flex-end; align-items: center; min-height: 48px; }

.card { display: flex; flex-direction: column; gap: 12px; background: var(--surface-container); border-radius: 28px; padding: 20px; }
.card.compact { padding: 12px 20px; }
.switch-row { display: flex; align-items: center; gap: 16px; cursor: pointer; }
.switch-row.disabled { cursor: default; opacity: .6; }
.switch-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.switch-title { font-size: 16px; }
.switch-detail { font-size: 12px; color: var(--on-surface-variant); }
.switch {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; margin: 0; cursor: pointer;
  width: 52px; height: 32px; border-radius: 16px; border: 2px solid var(--outline); background: var(--surface-container-highest);
  transition: background-color .2s, border-color .2s;
}
.switch::before {
  content: ""; position: absolute; top: 50%; left: 6px; width: 16px; height: 16px; margin-top: -8px;
  border-radius: 50%; background: var(--outline); transition: all .2s;
}
.switch:checked { background: var(--primary); border-color: var(--primary); }
.switch:checked::before { left: 22px; width: 24px; height: 24px; margin-top: -12px; background: var(--on-primary); }
.switch:disabled { cursor: default; }

.toast {
  position: fixed; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom)); z-index: 10;
  translate: -50% 16px; width: max-content; max-width: min(560px, calc(100% - 32px));
  padding: 14px 16px; border-radius: 4px; background: var(--inverse-surface); color: var(--inverse-on-surface);
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, translate .2s;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* ------------------------------------------------------------------ currency */

#currency { gap: 0; padding-bottom: 16px; }
.converter-area { display: flex; flex-direction: column; }
.converter { position: relative; display: flex; flex-direction: column; gap: 8px; }
.money-card { border-radius: 28px; padding: 14px 20px 18px 12px; background: var(--surface-container-high); color: var(--on-surface); }
.money-card.to { background: var(--primary-container); color: var(--on-primary-container); }
.money-row { display: flex; align-items: center; gap: 8px; height: 56px; }
.currency-button { display: flex; align-items: center; gap: 10px; flex: none; padding: 6px 8px; border-radius: 16px; }
.flag { font-size: 30px; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.code { font-size: 22px; font-weight: 600; }
.amount { flex: 1; min-width: 0; display: flex; justify-content: flex-end; }
.amount-value {
  padding: 0 4px; border-radius: 8px; white-space: nowrap; font-size: 34px; font-weight: 500; line-height: 1.25;
  overflow: hidden; max-width: 100%;
}
button.amount-value { text-align: right; }
.amount.dim .amount-value { opacity: .45; }
.amount.selected .amount-value { background: color-mix(in srgb, var(--primary) 16%, transparent); }
.money-sub { display: flex; gap: 12px; padding-left: 8px; font-size: 14px; }
.money-sub span { opacity: .75; }
.money-sub .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swap {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; background: var(--primary); color: var(--on-primary); border: 4px solid var(--surface);
}
.swap .icon { transition: rotate .3s; }
.rate-info { display: grid; gap: 2px; padding: 12px 8px; font-size: 14px; }
.rate-date { font-size: 12px; color: var(--on-surface-variant); }
.rate-date.old { color: var(--error); }
.keypad {
  flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; gap: 8px;
  min-height: 216px; max-height: 380px; margin-top: auto;
}
.key {
  display: grid; place-items: center; border-radius: 20px; background: var(--surface-container-high); color: var(--on-surface);
  font-size: 26px; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.key.op { background: var(--secondary-container); color: var(--on-secondary-container); }
.key.back { background: var(--tertiary-container); color: var(--on-tertiary-container); }

@media (orientation: landscape) and (max-height: 540px) {
  #currency { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
  .keypad { height: calc(100dvh - 64px - 24px); min-height: 0; margin-top: 8px; }
}

.picker {
  border: 0; padding: 0; margin: 0; width: 100%; max-width: none; height: 100%; max-height: none;
  background: var(--surface); color: var(--on-surface);
}
.picker::backdrop { background: rgb(0 0 0 / .4); }
@media (min-width: 700px) and (min-height: 600px) {
  .picker { margin: auto; width: 520px; height: min(760px, 90vh); border-radius: 28px; }
}
.picker-inner { display: flex; flex-direction: column; height: 100%; }
.picker-bar {
  display: flex; align-items: center; gap: 4px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px 4px;
  border-bottom: 1px solid var(--outline-variant);
}
.search { flex: 1; display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 4px 0 16px; border-radius: 28px; background: var(--surface-container-high); }
.search > .icon { color: var(--on-surface-variant); }
.search input { flex: 1; min-width: 0; border: 0; background: none; font-size: 16px; }
.search input:focus { outline: none; }
.search:focus-within { outline: 2px solid var(--primary); }
.picker-list { flex: 1; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
.picker-section { padding: 20px 20px 4px; font-size: 14px; font-weight: 500; color: var(--primary); }
.currency-row { display: flex; align-items: center; gap: 16px; width: 100%; padding: 10px 20px; text-align: left; }
.currency-row .flag { font-size: 28px; }
.currency-row .text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.currency-row .sub { font-size: 14px; color: var(--on-surface-variant); }
.currency-row[aria-selected="true"] .title { font-weight: 600; }
.currency-row .tick { color: var(--primary); }
.empty { padding: 24px; color: var(--on-surface-variant); }

/* ------------------------------------------------------------------ settings */

.section-title { margin: 8px 0 0 8px; font-size: 14px; font-weight: 500; color: var(--primary); }
.label { font-size: 14px; font-weight: 500; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 4px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; border-radius: 16px; font-size: 12px; font-weight: 500; }
.ring { display: grid; place-items: center; width: 52px; height: 52px; padding: 5px; border-radius: 50%; border: 3px solid transparent; }
.swatch[aria-checked="true"] .ring { border-color: var(--primary); }
.dot {
  grid-area: 1 / 1; width: 100%; height: 100%; border-radius: 50%;
  background: conic-gradient(from -90deg, var(--p) 0 180deg, var(--t) 180deg 270deg, var(--s) 270deg 360deg);
}
.ring .tick { grid-area: 1 / 1; display: none; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--pc); color: var(--opc); }
.ring .tick .icon { width: 16px; height: 16px; }
.swatch[aria-checked="true"] .tick { display: grid; }
.status { display: flex; align-items: center; gap: 12px; }
.status-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.status-detail { font-size: 12px; color: var(--on-surface-variant); }
.divider { height: 1px; background: var(--outline-variant); margin: 4px 0; }
.about-name { font-size: 16px; font-weight: 500; }
.muted { color: var(--on-surface-variant); }
.card p { margin: 0; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 1ms !important; }
}
