:root {
  color-scheme: light dark;
  --bg: #0b1220;
  --panel: rgba(255, 255, 255, 0.07);
  --panel-2: rgba(255, 255, 255, 0.1);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --focus: rgba(99, 179, 237, 0.45);
  --primary: #63b3ed;
  --danger: #ff6b6b;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --panel: rgba(0, 0, 0, 0.04);
    --panel-2: rgba(0, 0, 0, 0.07);
    --text: rgba(0, 0, 0, 0.88);
    --muted: rgba(0, 0, 0, 0.6);
    --line: rgba(0, 0, 0, 0.12);
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: radial-gradient(1200px 600px at 20% -20%, rgba(99, 179, 237, 0.25), transparent),
    radial-gradient(900px 500px at 100% 0%, rgba(255, 107, 107, 0.12), transparent),
    var(--bg);
  color: var(--text);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 10px;
  max-width: 1100px;
  margin: 0 auto;
}

.app-header__name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.app-header__hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
}

.badge--offline {
  background: rgba(255, 107, 107, 0.13);
  border-color: rgba(255, 107, 107, 0.3);
}

.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 0;
  backdrop-filter: blur(10px);
}

.tabs__list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 6px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  scrollbar-width: none;
}

.tabs__list::-webkit-scrollbar {
  display: none;
}

.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease;
  white-space: nowrap;
}

.tab:active {
  transform: scale(0.98);
}

.tab[aria-selected="true"] {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

.tab:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.panels {
  margin-top: 14px;
}

.panel {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: clip;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.panel__title {
  font-size: 14px;
  font-weight: 700;
}

.panel__body {
  padding: 14px;
}

.split {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 860px) {
  .split {
    grid-template-columns: 1fr 1fr;
  }
}

.field {
  display: grid;
  gap: 8px;
}

.field__label {
  font-size: 12px;
  color: var(--muted);
}

textarea,
input[type="text"],
input[type="number"] {
  width: 100%;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

textarea:focus,
input[type="text"]:focus,
input[type="number"]:focus {
  border-color: rgba(99, 179, 237, 0.6);
  box-shadow: 0 0 0 3px rgba(99, 179, 237, 0.18);
}

textarea {
  min-height: 260px;
  font-family: var(--mono);
  line-height: 1.4;
  resize: vertical;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.btn--primary {
  border-color: rgba(99, 179, 237, 0.4);
  background: rgba(99, 179, 237, 0.18);
}

.btn--danger {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.12);
}

.preview-frame {
  width: 100%;
  min-height: 260px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
}

.note {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.35;
}

.calc {
  display: grid;
  gap: 10px;
}

.calc__result {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.06);
}

.calc__result--error {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.08);
}

.calc__value {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.calc__error {
  min-height: 16px;
  font-size: 12px;
  color: rgba(255, 107, 107, 0.92);
  margin-top: -4px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.keypad__eval {
  border-color: rgba(99, 179, 237, 0.5);
}

.currency-rows {
  display: grid;
  gap: 10px;
}

.currency-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.06);
}

.currency-row__meta {
  min-width: 160px;
  display: grid;
  gap: 2px;
}

.currency-row__code {
  font-size: 13px;
  font-weight: 750;
}

.currency-row__name {
  font-size: 12px;
  color: var(--muted);
}

.rates {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.rates__grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 860px) {
  .rates__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.rates__item {
  display: grid;
  gap: 6px;
}

.rates__code {
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 520px) {
  .currency-row {
    flex-direction: column;
    align-items: stretch;
  }
  .currency-row__meta {
    min-width: auto;
  }
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: end center;
  padding: 16px;
  z-index: 60;
}

.sheet {
  width: 100%;
  max-width: 820px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--panel-2), black 12%);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: min(80vh, 720px);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.sheet__title {
  font-size: 14px;
  font-weight: 800;
}

.sheet__body {
  padding: 14px;
  overflow: auto;
}

.sheet__footer {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.06);
}

.history-item__meta {
  display: grid;
  gap: 3px;
  cursor: pointer;
}

.history-item__name {
  font-size: 13px;
  font-weight: 750;
}

.history-item__when {
  font-size: 12px;
  color: var(--muted);
}

.history-item__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 14px;
  display: grid;
  place-items: center;
  pointer-events: none;
  padding: 0 16px;
  z-index: 50;
}

.toast {
  pointer-events: auto;
  max-width: 900px;
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in oklab, var(--panel-2), black 10%);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}

.toast--error {
  border-color: rgba(255, 107, 107, 0.4);
  background: color-mix(in oklab, rgba(255, 107, 107, 0.14), var(--panel-2) 70%);
}

.toast__title {
  font-size: 13px;
  font-weight: 750;
  margin-bottom: 2px;
}

.toast__msg {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
  word-break: break-word;
}

.toast__hint {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}

.noscript {
  max-width: 1100px;
  margin: 16px auto;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}
