/* MaliMoto: high-contrast dark theme, fiery amber/coral accent */
:root {
  --bg: #0B0D10;
  --card: #14171C;
  --card-2: #1B1F26;
  --line: #262B33;
  --text: #F5F2EE;
  --muted: #A8A29E;
  --faint: #78716C;
  --accent: #F97316;
  --accent-2: #FB923C;
  --accent-ink: #1A0B02;
  --good: #22C55E;
  --bad: #EF4444;
  --radius: 16px;
  --nav-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
}
button, input, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
.hidden { display: none !important; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(11, 13, 16, 0.94);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(145deg, #2A1407, #120802);
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.4);
}
h1 { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: -0.02em; line-height: 1; }
h1 span { color: var(--accent); }
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--line); font-size: 18px; cursor: pointer;
}

main { padding: 0 16px; max-width: 640px; margin: 0 auto; }
.tab-panel { display: none; animation: fade 0.18s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-head { margin: 18px 0 10px; }
.section-head.small { margin-top: 26px; }
h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
h3 { margin: 0 0 8px; font-size: 16px; font-weight: 800; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.fine { color: var(--faint); font-size: 12px; text-align: center; margin: 18px 0 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.hint.center { text-align: center; }
.opt { color: var(--faint); font-weight: 400; font-size: 12px; }

/* Chips */
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 2px 16px;
}
form .chips { margin: 0; padding: 2px 0; flex-wrap: wrap; overflow: visible; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--muted); font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.chip[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.saved-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.saved-toggle input { accent-color: var(--accent); width: 18px; height: 18px; }

/* Cards */
.feed, .list { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.p-card { position: relative; }
.p-top { display: flex; gap: 12px; align-items: flex-start; }
.p-emoji {
  flex: none; width: 52px; height: 52px; border-radius: 14px;
  display: grid; place-items: center; font-size: 28px; background: var(--card-2);
}
.p-title { flex: 1; min-width: 0; }
.p-cat { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-2); }
.p-name { margin: 2px 0 4px; font-size: 17px; font-weight: 800; line-height: 1.25; }
.p-price { font-size: 20px; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; }
.p-price small { font-size: 12px; color: var(--muted); font-weight: 600; }
.save-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--card-2); border: 1px solid var(--line); font-size: 18px; cursor: pointer;
  filter: grayscale(1); opacity: 0.7;
}
.save-btn[aria-pressed="true"] { filter: none; opacity: 1; border-color: var(--accent); }

.intel { margin: 14px 0 0; display: grid; gap: 10px; }
.intel-row { display: grid; grid-template-columns: 28px 1fr; gap: 8px; }
.intel-ico { font-size: 18px; line-height: 1.4; text-align: center; }
.intel-k { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.intel-v { font-size: 14px; color: var(--text); }
.tag {
  display: inline-block; font-size: 12px; font-weight: 800; padding: 1px 8px; border-radius: 999px;
  background: rgba(249, 115, 22, 0.14); color: var(--accent-2); margin-right: 4px;
}
.heat { display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.heat div { font-size: 14px; }
.heat b { font-weight: 800; }
.heat .flames { letter-spacing: -2px; margin-right: 4px; }

.p-actions { display: flex; gap: 8px; margin-top: 14px; }
.p-actions .btn { flex: 1; }
.note-box { margin-top: 10px; }
.note-box textarea {
  width: 100%; min-height: 70px; resize: vertical;
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; font: inherit; font-size: 14px;
}
.note-box textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Buttons */
.btn {
  min-height: 46px; padding: 0 16px; border-radius: 14px;
  background: var(--card-2); border: 1px solid var(--line);
  color: var(--text); font-weight: 800; font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active, .chip:active, .nav-btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: 0.6; }
.btn.danger { border-color: rgba(239, 68, 68, 0.5); color: #FCA5A5; }
.btn.block { width: 100%; margin-top: 14px; }
.btn.copied { background: var(--good); border-color: var(--good); color: #04130A; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Forms */
.form label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 12px 0 6px; }
.form label:first-child { margin-top: 0; }
input[type=text], input[type=number], input[type=tel], input[type=password], select {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; font-size: 16px;
}
input::placeholder { color: var(--faint); }
select {
  appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 22px) 52%, calc(100% - 16px) 52%;
  background-size: 6px 6px; background-repeat: no-repeat;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.calc {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px;
}
.calc > div { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.calc .k { display: block; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.calc .v { display: block; font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums; }
.v.good { color: var(--good); } .v.bad { color: var(--bad); } .v.ok { color: var(--accent-2); }

.result { margin-top: 14px; }
.result .caption {
  white-space: pre-wrap; background: var(--bg); border: 1px dashed var(--accent);
  border-radius: 12px; padding: 12px; font-size: 15px; margin-top: 10px;
}
.result .src { font-size: 12px; color: var(--faint); margin-top: 8px; }
.mini { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mini .m-name { font-weight: 800; }
.mini .m-meta { font-size: 13px; color: var(--muted); }
.mini .m-actions { display: flex; gap: 6px; }
.mini .m-actions button { min-height: 38px; padding: 0 10px; font-size: 14px; }

/* Guide */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.seg-btn { min-height: 40px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-weight: 800; font-size: 13px; cursor: pointer; }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); }
.g-card h3 { margin-bottom: 2px; }
.g-area { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.g-row { font-size: 14px; margin: 6px 0; }
.g-row b { color: var(--accent-2); font-weight: 800; }
.g-card ul, .rules ul { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.g-card li, .rules li { margin: 4px 0; }
.g-watch { margin-top: 10px; font-size: 13px; padding: 8px 10px; border-radius: 10px; background: rgba(239, 68, 68, 0.1); color: #FCA5A5; }
.rules { margin-top: 14px; border-color: rgba(249, 115, 22, 0.4); }
.cmp { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmp th, .cmp td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cmp th { color: var(--accent-2); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.cmp td:first-child { font-weight: 800; white-space: nowrap; }
.cmp-wrap { overflow-x: auto; padding: 4px 10px; }

/* Bottom nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(11, 13, 16, 0.97); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.nav-btn {
  border: 0; background: none; color: var(--faint); font-size: 12px; font-weight: 800;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
.nav-btn span { font-size: 22px; filter: grayscale(1); opacity: 0.6; }
.nav-btn.active { color: var(--accent); }
.nav-btn.active span { filter: none; opacity: 1; }

/* Settings sheet */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet-inner {
  width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  animation: up 0.2s ease;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-inner label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 12px 0 6px; }
.sheet-inner h3 { margin-top: 22px; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); font-weight: 800; font-size: 14px;
  padding: 10px 16px; border-radius: 999px; z-index: 30; transition: all 0.2s ease;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
