/* thewordsword.com */
:root {
  --bg: #f4f5f7; --panel: #ffffff; --text: #16181d; --muted: #646a76; --line: #e3e5ea; --field: #f8f9fb;
  --accent: #e8501a; --accent-ink: #ffffff; --accent-soft: rgba(232, 80, 26, .1); --focus: rgba(232, 80, 26, .35);
  --steel: linear-gradient(90deg, #8b93a3, #d9dde4 45%, #9aa2b1);
  --ok: #138a5b; --err: #c42b2b;
  --ui: "Instrument Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1013; --panel: #16191e; --text: #e8eaee; --muted: #959cab; --line: #262b33; --field: #1c2027;
    --accent: #ff6a2b; --accent-ink: #160a04; --accent-soft: rgba(255, 106, 43, .14); --focus: rgba(255, 106, 43, .4);
    --steel: linear-gradient(90deg, #5b6372, #c7ccd6 45%, #6b7383); --ok: #3ccf91; --err: #ff6b6b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1013; --panel: #16191e; --text: #e8eaee; --muted: #959cab; --line: #262b33; --field: #1c2027;
  --accent: #ff6a2b; --accent-ink: #160a04; --accent-soft: rgba(255, 106, 43, .14); --focus: rgba(255, 106, 43, .4);
  --steel: linear-gradient(90deg, #5b6372, #c7ccd6 45%, #6b7383); --ok: #3ccf91; --err: #ff6b6b; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--ui); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
code { font-family: var(--mono); font-size: .88em; background: var(--accent-soft); color: var(--accent); padding: .05em .3em; border-radius: 4px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem clamp(16px, 3vw, 28px); }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--text); }
.logo { width: 30px; height: 30px; }
.logo .blade { fill: var(--accent); }
.logo .hilt { fill: none; stroke: var(--text); stroke-width: 2.4; stroke-linecap: round; }
.wordmark { font: 500 1.2rem/1 var(--ui); letter-spacing: -.01em; }
.wordmark b { font-weight: 700; }
.top-nav { display: flex; align-items: center; gap: .75rem; }
.top-nav a { color: var(--muted); text-decoration: none; font-weight: 500; padding: .4rem .5rem; border-radius: 8px; }
.top-nav a:hover { color: var(--text); background: var(--line); }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; padding: 0; }
.icon-btn:hover { border-color: var(--muted); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme-toggle .i-moon { fill: currentColor; stroke: none; }
.theme-toggle .i-sun, :root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
}

/* Workspace */
.workspace { flex: 1; display: grid; align-content: start; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 16px; padding: 0 clamp(16px, 3vw, 28px) 16px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.controls { position: sticky; top: 12px; padding: 14px; max-height: calc(100vh - 24px); overflow: auto; }
.results { padding: 18px 20px; min-height: 60vh; }

.tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; }
.tabs button { flex: 1 1 auto; border: 0; background: transparent; padding: .5rem .6rem; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .86rem; color: var(--muted); white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--line); }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.field { display: block; margin: 0 0 12px; }
.label { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .8rem; font-weight: 600; margin-bottom: 5px; }
.hint { font-weight: 400; color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
textarea { resize: vertical; }
.mono { font-family: var(--mono) !important; }
.big { font-size: 1.05rem !important; font-weight: 500; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row .field { flex: 1 1 90px; }
.field.small { flex: 0 1 100px; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .88rem; margin: 0 0 10px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.note { font-size: .8rem; color: var(--muted); margin: 0 0 12px; }

.segmented { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.segmented label { flex: 1 1 auto; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 10px; font-size: .84rem; font-weight: 600; cursor: pointer; color: var(--muted); }
.segmented input:checked + span { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.cheats { margin: 4px 0 12px; font-size: .84rem; }
.cheats summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.cheats dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; }
.cheats dt { font-family: var(--mono); font-size: .8rem; color: var(--accent); white-space: nowrap; }
.cheats dd { margin: 0; color: var(--muted); }
.examples button, .quick button { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.examples button { font-family: var(--mono); font-size: .8rem; margin-right: .4rem; }

#banks .field { margin-bottom: 8px; }
.bank-actions { display: flex; gap: 8px; margin-bottom: 10px; }

.list-picker { border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 4px; }
.list-picker .ghost { margin: -4px 0 12px; }

.primary { width: 100%; border: 0; border-radius: 12px; padding: .8rem 1rem; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1rem; cursor: pointer; letter-spacing: .01em; }
.primary:hover { filter: brightness(1.06); }
.primary:disabled { opacity: .6; cursor: progress; }
.ghost { border: 1px solid var(--line); background: transparent; border-radius: 9px; padding: .45rem .7rem; cursor: pointer; font-size: .84rem; font-weight: 600; color: var(--text); }
.ghost:hover { border-color: var(--muted); }
.ghost.small { padding: .3rem .6rem; font-size: .8rem; }

/* Results */
.status { margin-bottom: 14px; }
.bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; position: relative; }
.fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 6px; transition: width .2s ease; }
.bar.indeterminate .fill { width: 30%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { left: -30%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .bar.indeterminate .fill { animation: none; width: 100%; opacity: .5; } }
.status-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 8px; font-size: .86rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.status.done .fill { background: var(--ok); }
.status.error .fill { background: var(--err); }

.result-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.result-tools .count { font-weight: 700; margin-right: auto; }
.result-tools input { flex: 0 1 200px; padding: .4rem .6rem !important; font-size: .86rem; }
.result-tools select { width: auto; padding: .4rem .5rem; font-size: .86rem; }
.message { padding: .7rem .9rem; border-radius: 10px; background: var(--accent-soft); margin-bottom: 14px; font-size: .9rem; }
.message.error { background: color-mix(in srgb, var(--err) 12%, transparent); color: var(--err); }

.words { list-style: none; margin: 0; padding: 0; columns: 15rem auto; column-gap: 1.5rem; font-family: var(--mono); font-size: .92rem; }
.words li { break-inside: avoid; padding: .2rem .35rem; border-radius: 6px; display: flex; justify-content: space-between; gap: .75rem; }
.words li:hover { background: var(--field); }
.words .meta { color: var(--muted); font-size: .76rem; white-space: nowrap; }
.words.wide { columns: 26rem auto; }

.solutions { display: grid; gap: 10px; }
.solution { border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; background: var(--field); }
.solution:first-child { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.solution p { margin: 0; font-family: var(--mono); font-size: 1rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.solution .sol-meta { display: flex; justify-content: space-between; gap: 1rem; font-size: .76rem; color: var(--muted); margin-bottom: .35rem; }
.solution .key { font-family: var(--mono); font-size: .76rem; color: var(--muted); margin-top: .5rem; overflow-wrap: anywhere; }

.empty { max-width: 38rem; padding: clamp(1rem, 6vh, 4rem) 0; }
.empty h1 { font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.05; letter-spacing: -.03em; margin: 0 0 .8rem; }
.empty h1::after { content: ""; display: block; width: 4.5rem; height: 5px; margin-top: .9rem; border-radius: 3px; background: var(--steel); }
.empty p { color: var(--muted); font-size: 1.02rem; }
.quick { list-style: none; padding: 0; margin: 1.25rem 0; display: grid; gap: .55rem; }
.quick button { font-size: .98rem; text-align: left; }
.small-print { font-size: .88rem !important; }

/* Dialog */
dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--panel); color: var(--text); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45); }
dialog::backdrop { background: rgba(10, 12, 16, .55); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.dialog-head h2 { margin: 0; font-size: 1.15rem; }
.upload { padding: 8px 16px 14px; }
.drop { display: block; border: 1.5px dashed var(--line); border-radius: 12px; padding: 1.1rem; text-align: center; color: var(--muted); cursor: pointer; margin-bottom: 12px; font-size: .9rem; }
.drop.over, .drop:hover { border-color: var(--accent); color: var(--text); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.upload-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: .84rem; color: var(--muted); }
.upload-progress .bar { flex: 1; }
.my-lists { border-top: 1px solid var(--line); padding: 12px 16px 16px; }
.my-lists h3 { margin: 0 0 8px; font-size: .9rem; }
.my-lists ul { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.my-lists li { display: flex; align-items: center; gap: 8px; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 10px; font-size: .88rem; }
.my-lists li span { margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-lists li small { color: var(--muted); }
.my-lists .empty-mine { color: var(--muted); border-style: dashed; }

.foot { padding: 0 clamp(16px, 3vw, 28px) 20px; font-size: .8rem; color: var(--muted); }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .controls { position: static; max-height: none; }
  .results { min-height: 0; }
  .empty { padding: .5rem 0; }
}
@media (max-width: 560px) {
  .result-tools input { flex: 1 1 100%; order: 9; }
  .result-tools .count { flex: 1 1 100%; }
}
/* JetBrains Mono merges "..", "//", "->" etc. into ligatures; in patterns every character must stay visible */
.mono, code, .words, .solution p, .solution .key, .cheats dt, .examples button, .guide td:first-child {
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0;
}
/* long entries wrap inside their column instead of running into the next one */
.words li > span:first-child { min-width: 0; overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; }
.words .meta { flex: none; }
.words li > span:first-child { padding-left: 1.4em; text-indent: -1.4em; }  /* wrapped lines indent under their entry */
