:root {
  --bg: #121214;
  --bg-2: #161618;
  --ink: #f5f5f7;
  --muted: #a1a1aa;
  --line: rgba(255, 255, 255, 0.08);
  --card: rgba(30, 30, 34, 0.78);
  --accent: #f97316;
  --accent-ink: #ffffff;
  --soon: #fdba74;
  --soon-bg: rgba(249, 115, 22, 0.16);
  --bad: #fca5a5;
  --bad-bg: rgba(248, 113, 113, 0.16);
  --ok: #34d399;
  --ok-bg: rgba(16, 185, 129, 0.16);
  --copper-top: #3a2418;
  --copper-bottom: #1c1715;
  --space: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

*::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Nirmala UI", "Leelawadee UI", "Microsoft YaHei", "Yu Gothic UI", "Malgun Gothic", sans-serif;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(520px 280px at 0% 0%, rgba(234, 88, 12, 0.22), transparent 70%),
    var(--bg);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 16px 12px 96px;
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--copper-top) 0%, var(--copper-bottom) 100%);
}

.eyebrow {
  margin: 0 0 4px;
  color: #e7c4a8;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h1::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-inline-end: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.22);
  vertical-align: 1px;
}

.lang select {
  max-width: 42vw;
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
}

.lead {
  margin: 14px 2px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.view-switch {
  display: flex;
  gap: 4px;
  margin-top: 14px;
}

.view-switch .filter-btn {
  flex: 1;
  padding: 6px 4px;
  font-size: 12px;
}

.market-banner {
  display: block;
  width: 100%;
  margin-top: 16px;
  text-align: start;
  border-radius: 16px;
  border: 1px solid rgba(249, 115, 22, 0.45);
  background: rgba(249, 115, 22, 0.14);
  color: var(--ink);
  padding: 14px 16px;
  cursor: pointer;
}

.market-banner strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.market-banner span {
  display: block;
  margin-top: 4px;
  color: var(--soon);
  font-size: 13px;
  font-weight: 600;
}

.market-lead {
  margin: 14px 2px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.section-title {
  margin: 18px 0 0;
  font-size: 15px;
  font-weight: 600;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.compare-grid .money-card { margin-top: 12px; }

.compare-grid .money-figure { font-size: 18px; }

.delta-line {
  margin: 8px 0 0;
  color: var(--soon);
  font-size: 13px;
  font-weight: 600;
}

.item-actions button.edit-btn { flex: 1 1 100%; }

.money-card {
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(249, 115, 22, 0.14);
}

.money-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.money-figure {
  margin: 4px 0 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.cat-money {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cat-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 14px;
}

.cat-row strong { font-weight: 700; }

.waste-line {
  margin: 10px 0 0;
  color: var(--bad);
  font-size: 13px;
  font-weight: 600;
}

.period {
  display: flex;
  gap: 8px;
}

.period .field {
  flex: 1;
  min-width: 0;
}

.amount {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.summary {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--soon-bg);
  color: var(--soon);
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(12px);
}

.summary[hidden] { display: none; }

.filter-controls {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin-top: 16px;
  overflow: hidden;
}

.filter-btn {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 2px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
}

.filter-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.filter-controls.wrap {
  flex-wrap: wrap;
  overflow: visible;
}

.filter-controls.wrap .filter-btn {
  flex: 0 1 auto;
  padding: 4px 8px;
}

.list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  backdrop-filter: blur(16px);
  animation: rise 320ms ease both;
}

.item:nth-child(2) { animation-delay: 40ms; }
.item:nth-child(3) { animation-delay: 80ms; }
.item:nth-child(4) { animation-delay: 120ms; }
.item:nth-child(5) { animation-delay: 160ms; }

.item-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.item-copy { flex: 1; min-width: 0; }

.item h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.soon { background: var(--soon-bg); color: var(--soon); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.item-actions button,
.ghost,
.primary {
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.item-actions button,
.ghost {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink);
}

.item-actions button.quiet {
  flex: 1 1 100%;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.primary,
.add {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
}

.add {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(448px, calc(100% - 24px));
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(249, 115, 22, 0.28);
}

.add:disabled,
.primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.empty {
  margin: 28px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
}

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}

.dialog {
  position: relative;
  width: min(480px, 100%);
  max-height: 100vh;
  overflow: auto;
  background: rgba(22, 22, 24, 0.94);
  border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 16px 16px 24px;
  backdrop-filter: blur(18px);
}

.thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  flex: 0 0 auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
}

.photo-btn { width: 100%; }

.photo-preview {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 12px;
  margin-top: 8px;
}

.camera-panel video {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  background: #111;
  margin-top: 8px;
}

.camera-actions,
.file-pick {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.camera-actions .primary,
.camera-actions .ghost { flex: 1; }

.file-pick input { margin-top: 8px; }

.alert-line {
  margin: 8px 0 0;
  color: var(--soon);
  font-size: 13px;
  font-weight: 600;
}

.alert-line.is-off {
  color: var(--muted);
  font-weight: 500;
}

.alert-hint,
.price-hint {
  margin: 8px 0 0;
  color: var(--soon);
  font-size: 13px;
  font-weight: 600;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.field input,
.field select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg-2);
  color: var(--ink);
}

.form-error {
  margin: 12px 0 0;
  color: var(--bad);
  font-weight: 600;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.form-actions .primary { flex: 1.4; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .item { animation: none; }
}

@media (min-width: 720px) {
  .modal { place-items: center; }
  .dialog { border-radius: 16px; }
}
