:root {
  --bg: #f4f6f5; --card: #fff; --text: #1c2321; --muted: #6b7672; --line: #e2e7e5;
  --accent: #0f766e; --accent-text: #fff; --accent-soft: #e6f4f2;
  --danger: #b42318; --ok-bg: #e7f6ec; --err-bg: #fdecea; --star: #e5a50a;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615; --card: #1c2220; --text: #e8ecea; --muted: #94a09b; --line: #2c3431;
    --accent: #2bb3a3; --accent-text: #06201d; --accent-soft: #173431;
    --danger: #f97066; --ok-bg: #163222; --err-bg: #3a1a17;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 1rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.card h2:first-child { margin-top: 0; }
main { max-width: 960px; margin: 0 auto; padding: 16px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.top nav a { text-decoration: none; padding: 6px 10px; border-radius: 8px; color: var(--text); font-size: .95rem; white-space: nowrap; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }
.top nav a.on, .top nav a:hover { background: var(--accent-soft); }
.env-badge { background: #c2410c; color: #fff; text-align: center; font-size: .75rem; font-weight: 700; letter-spacing: .1em; padding: 2px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.empty { text-align: center; padding: 32px 16px; }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }
.section { font-size: 1rem; color: var(--muted); margin: 8px 0; font-weight: 600; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.flash-ok { background: var(--ok-bg); }
.flash-error { background: var(--err-bg); color: var(--danger); }

.use-result { background: var(--accent); color: var(--accent-text); border-radius: var(--radius); padding: 20px 16px; margin-bottom: 20px; text-align: center; animation: pop .35s ease-out; }
.use-result .use-icon { font-size: 2.2rem; line-height: 1; }
.use-result .use-text { font-size: 1.1rem; margin-top: 6px; }
.use-result .use-cost { font-size: 2.6rem; font-weight: 800; line-height: 1.15; }
.use-result .use-meta { opacity: .85; font-size: .9rem; }
.use-result .link { color: inherit; opacity: .85; margin-top: 6px; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.tile-head { text-decoration: none; color: var(--text); display: flex; flex-direction: column; padding-right: 26px; }
.tile-icon { font-size: 2rem; line-height: 1.2; }
.tile-name { font-weight: 650; overflow-wrap: anywhere; }
.tile-cost { font-size: 1.35rem; font-weight: 750; }
.tile-cost small { font-size: .75rem; font-weight: 400; color: var(--muted); }
.tile-meta { font-size: .8rem; color: var(--muted); margin-bottom: 8px; }
.tile .use-form { margin-top: auto; }
.tile .fav-form { position: absolute; top: 6px; right: 6px; }

.star { background: none; border: 0; font-size: 1.4rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px; }
.star.on { color: var(--star); }

button, .btn { font: inherit; cursor: pointer; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-text); border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 600; text-decoration: none; text-align: center; }
.btn-secondary { background: var(--accent-soft); color: var(--accent); }
.btn-use { width: 100%; background: var(--accent); color: var(--accent-text); border: 0; border-radius: 10px; padding: 12px; font-weight: 700; font-size: 1.05rem; touch-action: manipulation; }
.btn-use:active { transform: scale(.97); }
.btn-use[disabled] { opacity: .6; }
.btn-big { padding: 18px; font-size: 1.3rem; margin-bottom: 16px; }
.link { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; }
.danger { color: var(--danger); }

form.stack, .card form { display: flex; flex-direction: column; gap: 12px; }
form.inline { display: inline-flex; margin-right: 12px; }
form.row, .row { display: flex; gap: 10px; flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.row .icon-field { flex: 0 0 80px; }
.row .grow { flex: 1 1 200px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: .95rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
input, select { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); width: 100%; min-width: 0; }
input[type=checkbox] { width: auto; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.icon-field input { text-align: center; font-size: 1.3rem; padding: 6px; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-pick button { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-size: 1.3rem; padding: 2px 6px; }
.copy-row { display: flex; gap: 8px; }
details > summary { cursor: pointer; list-style: none; width: fit-content; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 12px; }
.archive { margin-top: 8px; }

.item-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.item-head h1 { margin: 0; }
.item-head .fav-form { margin-left: auto; }
.item-icon { font-size: 2.6rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stats > div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; font-size: .85rem; color: var(--muted); }
.stats span { display: block; font-size: 1.3rem; font-weight: 750; color: var(--text); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
tfoot th { color: var(--text); font-size: .95rem; border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
td a { text-decoration: none; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 4px 0; }
