/* Light UI after gtmguild.co: cream page, paper cards, forest buttons and top bar,
   olive accents, chartreuse only on forest. Light only, no dark mode. */
:root {
  --page: #f4f3e8;           /* gray-50 */
  --surface: #fafaf6;        /* cards, inputs */
  --text: #1f211a;           /* gray-900 */
  --text-muted: #53574a;     /* gray-500: labels, secondary text */
  --text-soft: #454839;      /* gray-600: subtitles */
  --text-strong: #383b2f;    /* gray-700: ghost button text */
  --border: #bdbcaa;         /* gray-300: inputs, ghost buttons */
  --border-soft: #d9d8ca;    /* gray-200: cards, row dividers */
  --hover-fill: #edecdf;     /* gray-100 */
  --primary: #212e21;        /* forest */
  --primary-hover: #3a4c3a;
  --accent: #ebfc72;         /* chartreuse, only on --primary */
  --olive-50: #ece8d4;
  --olive-100: #e3dfc8;
  --olive-300: #bdb594;
  --olive-700: #5a5540;
  --link: #5a5540;           /* olive-700 */
  --link-underline: #bdb594; /* olive-300 */

  /* Status colors stay stock Tailwind. */
  --green: #15803d;          /* green-700 */
  --green-fill: #16a34a;     /* green-600 */
  --green-soft: #f0fdf4;     /* green-50 */
  --red: #b91c1c;            /* red-700 */
  --red-ring: #dc2626;       /* red-600 */
  --red-soft: #fef2f2;       /* red-50 */
  --amber: #f59e0b;          /* amber-500 */
  --amber-soft: #fffbeb;     /* amber-50 */
  --amber-border: #fde68a;   /* amber-200 */
  --amber-100: #fef3c7;      /* amber-100: current row */
  --amber-950: #451a03;      /* amber-950: text on amber */

  --control-h: 38px;
  --control-h-sm: 30px;
  --radius: 6px;
  --radius-card: 8px;
  --shadow: 0 1px 2px rgba(20, 22, 15, .05);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.wrap { max-width: 1152px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 16px; font-weight: 600; margin: 0; }
h2 { font-size: 18px; line-height: 28px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 16px; font-weight: 600; margin: 16px 0 4px; }
p { margin: 8px 0; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--olive-50); color: var(--olive-700); padding: 1px 4px; border-radius: 4px; }
a, .link { color: var(--link); text-decoration: underline; text-decoration-color: var(--link-underline); text-underline-offset: 2px; }
a:hover, .link:hover { text-decoration-color: currentColor; }
.muted { color: var(--text-muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- top bar (forest) ---------- */
.topbar { background: var(--primary); color: var(--page); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 52px; padding-top: 8px; padding-bottom: 8px; font-size: 14px; }
.topbar h1 { color: var(--accent); font-size: 15px; letter-spacing: .01em; }
.topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar .muted { color: rgba(244, 243, 232, .8); }
#sheetName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; font-size: 14px; }
.topbar .btn-ghost { background: transparent; border-color: rgba(244, 243, 232, .35); color: var(--page); }
.topbar .btn-ghost:hover { background: var(--primary-hover); border-color: rgba(244, 243, 232, .5); }
.topbar .btn:focus-visible { outline-color: var(--accent); }

/* ---------- layout ---------- */
main { padding-top: 32px; padding-bottom: 48px; }
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-card); padding: 20px; margin-bottom: 24px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .025em; color: var(--text-muted); }
label .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.hint { font-weight: 400; color: var(--text-muted); font-size: 12px; text-transform: none; letter-spacing: 0; }
input[type=url], input[type=password], input[type=search], input[type=text], select, textarea {
  font: inherit; font-size: 14px; line-height: 20px; font-weight: 400; color: var(--text); background: var(--surface);
  text-transform: none; letter-spacing: 0;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; width: 100%; min-width: 0;
  min-height: var(--control-h);
}
select { padding-top: 0; padding-bottom: 0; height: var(--control-h); }
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text-muted); }
::placeholder { color: #666a5a; opacity: 1; } /* gray-400 */

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; margin-top: 16px; }
.setup-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-size: 14px; line-height: 20px; font-weight: 500; cursor: pointer; text-decoration: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-strong);
  border-radius: var(--radius); padding: 8px 12px; min-height: var(--control-h);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--hover-fill); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:disabled:hover { background: var(--surface); }
.btn-primary { background: var(--primary); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled:hover { background: var(--primary); }
.btn-ghost { background: var(--surface); }
.btn-small { min-height: var(--control-h-sm); padding: 4px 10px; font-size: 12px; line-height: 16px; }

/* ---------- setup ---------- */
.howto { background: var(--page); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 12px 16px; }
.howto summary { cursor: pointer; font-weight: 500; font-size: 14px; }
.howto ol { padding-left: 20px; margin: 12px 0; font-size: 15px; }
.howto li { margin-bottom: 8px; }
.code-actions { display: flex; gap: 6px; margin-top: 6px; }

.status { margin-top: 12px; font-size: 14px; min-height: 1px; }
.status.err { color: var(--red); background: var(--red-soft); padding: 8px 12px; border-radius: var(--radius); }
.status.ok { color: var(--green); }
.status.warn { color: var(--text); background: var(--olive-50); padding: 8px 12px; border-radius: var(--radius); font-weight: 500; }
.mapping-box { border: 1px solid var(--olive-300); background: var(--page); border-radius: var(--radius-card); padding: 4px 16px 16px; margin-top: 16px; }
.mapping-box select.need { border-color: var(--red-ring); outline: 1px solid var(--red-ring); outline-offset: -1px; }
.placeholder { color: var(--text-muted); text-align: center; padding: 28px 12px; margin: 0; border: 2px dashed var(--border-soft); border-radius: var(--radius-card); }

.setup-summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.setup-summary::-webkit-details-marker { display: none; }
.setup-summary h2 { margin: 0; }
.setup-summary h2::before { content: '▸'; display: inline-block; width: 1em; color: var(--text-muted); transition: transform .15s; }
.setup-details[open] > .setup-summary h2::before { transform: rotate(90deg); }
.setup-details[open] > .setup-summary { margin-bottom: 12px; }
.tab-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.tab-row label { min-width: 220px; }
.code-row { display: flex; gap: 8px; max-width: 420px; }
.code-row input { flex: 1; }
.mapping { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0 16px; }

/* ---------- template ---------- */
.legend { margin-top: 12px; display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font: 12.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; cursor: pointer;
  background: var(--olive-50); color: var(--olive-700); border: 1px solid transparent; border-radius: 999px; padding: 2px 9px;
}
.tag:hover { border-color: var(--olive-300); background: var(--olive-100); }
.tag:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tag .desc { font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text-muted); margin-left: 4px; }
.tag.extra { background: transparent; border-color: var(--border-soft); color: var(--text-muted); }
.tag.extra:hover { border-color: var(--border); }
.preview { margin-top: 12px; }
.preview summary { cursor: pointer; font-size: 14px; color: var(--text-muted); }
.preview pre { white-space: pre-wrap; word-wrap: break-word; font: inherit; font-size: 15px; background: var(--page); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 12px; margin: 8px 0 0; }
.preview .missing { color: var(--red); background: var(--red-soft); border-radius: 3px; }

/* ---------- contacts ---------- */
.progress-text { font-size: 14px; color: var(--text-muted); }
.progress-text b { color: var(--text); font-weight: 600; }
.progress { height: 6px; background: var(--hover-fill); border-radius: 999px; overflow: hidden; margin-bottom: 16px; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .25s; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input { flex: 1 1 220px; }
.toolbar .btn-small { min-height: var(--control-h); font-size: 14px; padding: 8px 12px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; height: var(--control-h); }
.seg-btn { font: inherit; font-size: 14px; padding: 0 12px; background: var(--surface); color: var(--text-strong); border: 0; cursor: pointer; }
.seg-btn:hover { background: var(--hover-fill); }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--primary); color: var(--page); font-weight: 500; }
.seg-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border-soft); }
.list-head { display: flex; align-items: flex-end; gap: 12px; padding: 4px 6px 6px; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .025em; color: var(--text-muted); }
.list-head .num { font-size: 12px; }
.list-head .col-li, .list-head .col-msg { width: 150px; text-align: center; flex: none; }
.item .btn-li, .item .btn-msg { width: 100%; justify-content: center; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--border-soft); }
.item:hover { background: var(--page); }
.item.is-done .who .name { color: var(--text-muted); }
.item.is-current, .item.is-current:hover {
  background: var(--amber-100); box-shadow: inset 6px 0 0 var(--amber), inset 0 0 0 1px var(--amber);
  border-bottom-color: var(--amber);
}
.name-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cur-badge { display: none; flex: none; font-size: 11px; line-height: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--amber-950); background: var(--amber); border-radius: 999px; padding: 2px 8px; }
.item.is-current .cur-badge { display: inline-block; }
.item.is-current .btn-li { box-shadow: 0 0 0 2px var(--amber); }
.num { color: var(--text-muted); font-size: 12px; width: 78px; white-space: nowrap; text-align: center; flex: none; font-variant-numeric: tabular-nums; }
.who { flex: 1; min-width: 0; }
.who .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .meta { color: var(--text-muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .co:not(:empty) + .ttl:not(:empty)::before { content: ' · '; font-style: normal; }
.who .ttl { font-style: italic; }
.actions { display: flex; gap: 6px; flex: none; align-items: flex-start; margin-left: auto; }
.act { display: flex; flex-direction: column; align-items: stretch; gap: 3px; width: 150px; flex: none; }
.sub { font-size: 11px; color: var(--olive-700); font-weight: 500; text-align: center; overflow-wrap: anywhere; }
.sub-msg { color: var(--green); }
.sub:empty { display: none; }
.btn-li { background: var(--primary); color: #fff; border-color: transparent; }
.btn-li:hover { background: var(--primary-hover); }
.btn-li:disabled:hover { background: var(--primary); }
.btn-msg .check { display: inline-block; width: 16px; height: 16px; border: 1.5px solid var(--text-muted); border-radius: 4px; line-height: 13px; text-align: center; font-size: 12px; background: var(--surface); }
.btn-msg.done { background: var(--green-fill); border-color: var(--green-fill); color: #fff; }
.btn-msg.done:hover { background: var(--green); border-color: var(--green); }
.btn-msg.done .check { border-color: #fff; background: #fff; color: var(--green); }
.btn-msg.saving { opacity: .6; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--primary); color: var(--page); padding: 10px 16px; border-radius: var(--radius-card); font-size: 14px;
  box-shadow: 0 4px 12px rgba(20, 22, 15, .18);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); color: #fff; }

@media (max-width: 680px) {
  main { padding-top: 16px; }
  .card { padding: 16px; margin-bottom: 16px; }
  .list-head { display: none; }
  .item .num { display: block; width: 100%; text-align: left; order: -1; margin-bottom: -6px; }
  .item .num::before { content: 'Sheet row '; }
  .item .btn-li, .item .btn-msg { width: auto; }
  .grid2, .mapping { grid-template-columns: 1fr; }
  .item { flex-wrap: wrap; }
  .num { display: none; }
  .actions { width: 100%; }
  .actions .act { flex: 1; width: auto; }
  .actions .btn { width: 100%; justify-content: center; }
  #sheetName { display: none; }
}
