:root {
  --bg: #1d140e;
  --bg-2: #2a1d14;
  --panel: #f3e9d8;
  --panel-2: #e8dac3;
  --ink: #2b1d12;
  --ink-soft: #6b5440;
  --gold: #d4a64a;
  --gold-soft: #b48a3a;
  --line: rgba(212, 166, 74, .28);
  --danger: #a3402c;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(120% 60% at 50% 0%, #3a2819 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--panel);
  font: 15px/1.5 Inter, system-ui, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 720px; margin: 0 auto; padding: 20px 16px 96px; }

h1, h2, h3 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 700; margin: 0; letter-spacing: .01em; }
h1 { font-size: 36px; line-height: 1.1; color: var(--gold); }
h2 { font-size: 26px; color: var(--gold); margin-bottom: 4px; }
h3 { font-size: 20px; color: var(--gold); margin: 22px 0 8px; }
.sub { color: #bfa88a; margin: 4px 0 20px; }
.muted { color: #a8917a; font-size: 13px; }
a { color: inherit; text-decoration: none; }

/* ---- главная ---- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tile {
  position: relative; aspect-ratio: 1 / 1.05; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(160deg, #5a3b22, #2e1e12);
  border: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: flex-end; padding: 12px;
}
.tile svg { position: absolute; inset: 10% 18% 30%; width: 64%; height: 60%; stroke: var(--gold); fill: none; stroke-width: 3; opacity: .9; }
.tile span {
  position: relative; background: var(--panel); color: var(--ink); border-radius: 12px;
  text-align: center; font-weight: 600; padding: 10px 6px;
}
.tile:active { transform: scale(.98); }

/* ---- списки ---- */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--panel); color: var(--ink); border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .meta { color: var(--ink-soft); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.empty .title { color: var(--ink-soft); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex: none; }
.dot.off { background: #cdbca3; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  color: #e8d6b8; background: transparent; font: inherit; font-size: 14px;
}
.tab.on { background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight: 600; }

.search {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--panel); font: inherit; margin-bottom: 12px;
}

/* ---- карточка ---- */
.card { background: var(--panel); color: var(--ink); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--gold-soft); }
.card .text { white-space: pre-wrap; }
.card .text.empty { color: var(--ink-soft); font-style: italic; }
.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: rgba(212,166,74,.18); color: var(--gold); margin-right: 6px; }

/* ---- формы ---- */
label { display: block; font-size: 13px; color: #cdb592; margin: 12px 0 4px; }
input, textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--panel); font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 0; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: 12px; border: 0; font: inherit; font-weight: 600;
  background: var(--gold); color: var(--ink); cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--gold); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: #e08b74; border: 1px solid rgba(224,139,116,.4); }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

/* ---- расклад ---- */
.board {
  display: grid; gap: 8px; justify-content: center; margin: 8px 0 16px;
  padding: 16px 8px; border-radius: var(--radius); background: rgba(0,0,0,.25); border: 1px solid var(--line);
  overflow-x: auto;
}
.slot {
  width: 74px; min-height: 112px; border-radius: 10px; border: 1.5px dashed var(--gold-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 6px 4px; font-size: 11px; line-height: 1.25; color: #e8d6b8; cursor: pointer; background: transparent;
}
.slot .pn { color: var(--gold); font-weight: 600; margin-bottom: 4px; }
.slot.filled { border-style: solid; background: var(--panel); color: var(--ink); }
.slot.filled .pn { color: var(--gold-soft); }
.slot.rev .cn { transform: rotate(180deg); }
.slot .cn { font-weight: 600; }

.pos-edit { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.pos-edit .row input[type=number] { max-width: 80px; }

details.meaning { margin-top: 8px; }
details.meaning summary { cursor: pointer; color: var(--gold-soft); font-size: 13px; }
details.meaning .text { margin-top: 6px; font-size: 14px; }

/* ---- модалка ---- */
.modal { position: fixed; inset: 0; background: rgba(10,6,3,.7); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); border-top: 1px solid var(--line); width: 100%; max-width: 720px; max-height: 88vh;
  border-radius: 20px 20px 0 0; padding: 16px; overflow-y: auto;
}
.switch { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; color: #e8d6b8; }
.switch input { width: auto; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--panel); color: var(--ink); padding: 10px 16px; border-radius: 12px; font-weight: 500;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
[hidden] { display: none !important; }
.center { text-align: center; padding: 40px 0; color: #a8917a; }
