:root {
  --bg: #F8F9F1;
  --surface: #FFFFFF;
  --ink: #1B2A12;
  --muted: #5F6B57;
  --line: #E3E7D8;
  --pickle: #76B82A;
  --pickle-dark: #2C5410;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(27, 42, 18, .06), 0 4px 16px rgba(27, 42, 18, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; font-weight: 900; letter-spacing: -.01em; }
[hidden] { display: none !important; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: .9rem; }
code { background: #EEF2E3; padding: 1px 5px; border-radius: 4px; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 24px; height: 64px; }
.logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-size: 1.4rem; font-weight: 800; color: var(--ink); }
.logo b { color: var(--pickle); font-weight: 900; }
.logo-mark { width: 36px; height: 36px; flex: none; }
.logo.small { font-size: 1.15rem; }
.logo.small .logo-mark { width: 28px; height: 28px; }
.site-header nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.site-header nav a { text-decoration: none; font-weight: 700; padding: 8px 12px; border-radius: 10px; white-space: nowrap; color: var(--muted); }
.site-header nav a:hover { background: #F1F4E8; color: var(--ink); }
.site-header nav a.all { color: var(--pickle-dark); }
@media (max-width: 760px) { .site-header nav a:not(.all) { display: none; } }

/* Buttons */
.btn {
  --c: var(--pickle);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--c); color: #fff; border: 0; border-radius: 12px;
  font: inherit; font-weight: 800; padding: 12px 22px; cursor: pointer; text-decoration: none;
  transition: transform .1s, filter .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; }
.btn.big { font-size: 1.25rem; padding: 18px 40px; border-radius: 14px; box-shadow: 0 6px 18px color-mix(in srgb, var(--c) 35%, transparent); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #F3F6EA; }
.btn.small { padding: 8px 14px; font-size: .9rem; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row.center { justify-content: center; }
.btn-row .btn { flex: 1; }

/* Home */
.hero { text-align: center; padding: 64px 16px 32px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
.hero h1 span { color: var(--pickle); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 640px; margin: 0 auto; }
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; padding-top: 16px; padding-bottom: 48px; }
.tool-card {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; text-decoration: none; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s;
}
.tool-card:hover { transform: translateY(-3px); border-color: #CFD8BC; box-shadow: 0 10px 28px rgba(27, 42, 18, .1); }
.tool-card h3 { font-size: 1.2rem; margin: 14px 0 6px; }
.tool-card p { margin: 0; color: var(--muted); font-size: .95rem; }
.tools.mini { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); padding-bottom: 0; }
.tools.mini .tool-card { display: flex; align-items: center; gap: 12px; padding: 14px; }
.tools.mini h3 { margin: 0; font-size: 1.05rem; }
.ticon { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--c); color: #fff; flex: none; }
.ticon svg { width: 26px; height: 26px; }
.ticon.big { width: 72px; height: 72px; border-radius: 20px; margin-bottom: 16px; }
.ticon.big svg { width: 40px; height: 40px; }
.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; padding-bottom: 48px; }
.why > div { text-align: center; padding: 8px 16px; }
.why-i { font-size: 2rem; }
.why h3 { margin: 8px 0 4px; }
.why p { margin: 0; color: var(--muted); }

/* Tool upload */
.tool-hero { text-align: center; padding: 48px 16px 40px; }
.tool-hero h1 { font-size: clamp(2rem, 5vw, 3rem); }
.drop {
  --c: var(--pickle);
  margin: 32px auto 0; max-width: 720px; padding: 48px 16px; border-radius: 24px;
  border: 2px dashed color-mix(in srgb, var(--c) 45%, #fff); background: color-mix(in srgb, var(--c) 5%, #fff);
}
.drop p { margin: 14px 0 0; color: var(--muted); font-weight: 600; }
.privacy { color: var(--muted); font-size: .95rem; margin-top: 20px; }
.drop-overlay { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgba(118, 184, 42, .18); backdrop-filter: blur(2px); pointer-events: none; }
.drop-overlay div { background: var(--surface); padding: 24px 40px; border-radius: 20px; font-size: 1.5rem; font-weight: 900; box-shadow: var(--shadow); border: 3px dashed var(--pickle); }
body.dragging .drop-overlay { display: grid; }

/* Workspace */
.work { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; padding-top: 24px; padding-bottom: 48px; align-items: start; }
@media (max-width: 860px) { .work { grid-template-columns: 1fr; } }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
#fileInfo { font-weight: 700; color: var(--muted); overflow-wrap: anywhere; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
@media (max-width: 480px) { .items { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px; box-shadow: var(--shadow); user-select: none;
}
.sortable .card { cursor: grab; }
.card.sortable-ghost { opacity: .35; }
.card.sortable-chosen { box-shadow: 0 12px 30px rgba(27, 42, 18, .18); }
.card.error { border-color: #E5533D; }
.thumb { aspect-ratio: 3 / 4; display: grid; place-items: center; background: #F1F3EA; border-radius: 8px; overflow: hidden; }
.thumb img { max-width: 100%; max-height: 100%; display: block; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); transition: transform .2s; background: #fff; }
.thumb img.side { max-width: 75%; max-height: 75%; }
.meta { margin-top: 8px; font-size: .85rem; line-height: 1.3; min-width: 0; }
.meta .name { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .sub { color: var(--muted); }
.card.error .sub { color: #C4382A; }
.page .meta { text-align: center; font-weight: 700; color: var(--muted); }
.acts { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.card:hover .acts, .card:focus-within .acts { opacity: 1; }
@media (hover: none) { .acts { opacity: 1; } }
.acts button {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: #fff; cursor: pointer;
  display: grid; place-items: center; font-size: 16px; color: var(--ink); box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}
.acts button:hover { background: #F3F6EA; }
.acts button[data-act="remove"]:hover { background: #FDECEA; color: #C4382A; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #DCE3CC; border-top-color: var(--pickle); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Panel */
.panel { position: sticky; top: 88px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
@media (max-width: 860px) { .panel { position: static; } }
.panel h2 { font-size: 1.35rem; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.opt { display: block; margin: 0 0 16px; padding: 0; border: 0; font-weight: 700; font-size: .95rem; }
.opt legend { padding: 0; margin-bottom: 6px; }
.opt > span { display: block; margin-bottom: 6px; }
.opt small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; }
.opt input:not([type=radio]):not([type=checkbox]):not([type=range]), .opt select {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-weight: 600; background: #fff; color: var(--ink);
}
.opt input:focus, .opt select:focus { outline: 2px solid var(--pickle); outline-offset: 1px; }
.opt input[type=range] { display: block; width: 100%; margin-top: 10px; accent-color: var(--pickle); }
.radio, .check { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 6px 0; cursor: pointer; }
.check { margin-bottom: 16px; }
.radio input, .check input { accent-color: var(--pickle); width: 18px; height: 18px; }
.hint { color: var(--muted); font-size: .95rem; margin: 0 0 16px; }
.btn.run { width: 100%; font-size: 1.15rem; padding: 16px; }
.run-hint { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: .9rem; min-height: 1.2em; }

/* Result */
.result { padding-top: 48px; padding-bottom: 48px; }
.done { text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 40px 20px; box-shadow: var(--shadow); max-width: 640px; margin: 0 auto 40px; }
.done-icon { font-size: 3.5rem; animation: pop .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(.3) rotate(-30deg); opacity: 0; } }
.done h2 { font-size: 1.8rem; }
.done #resultText { color: var(--muted); margin: 0 0 24px; }
.done .btn-row { margin-top: 20px; }
.done .btn-row .btn { flex: none; }

/* FAQ */
.faq { max-width: 760px; padding-bottom: 56px; }
.faq h2 { text-align: center; font-size: 1.6rem; margin-bottom: 20px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin-bottom: 10px; }
.faq summary { font-weight: 800; cursor: pointer; }
.faq details p { margin: 10px 0 0; color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 32px 0 16px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; }
.site-footer p { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }
.foot-links { display: grid; grid-template-columns: repeat(2, auto); gap: 6px 32px; align-content: start; }
.foot-links a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: .95rem; }
.foot-links a:hover { color: var(--ink); }
.copy { text-align: center; color: var(--muted); font-size: .85rem; margin: 24px 0 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: calc(100% - 32px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 700; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
