:root {
  color-scheme: light;
  --ink: #1d2530;
  --muted: #66717f;
  --blue: #214bc7;
  --paper: #fffdf8;
  --line: #dce0e6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #eceae5;
  font-family: Arial, sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
#card-app { width: min(1540px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 64px; }
.site-return { margin: 0 0 10px; }
.site-return a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid #169b55;
  border-radius: 10px;
  background: #169b55;
  box-shadow: 0 4px 12px rgba(22, 155, 85, .22);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}
.site-return a:hover { border-color: #118047; background: #118047; }
.site-return a:focus-visible { outline: 3px solid rgba(22, 155, 85, .28); outline-offset: 2px; }
.hero, .panel { border-radius: 18px; background: #fff; box-shadow: 0 9px 28px rgba(28, 34, 42, .1); }
.hero { padding: 30px 34px; }
.eyebrow { margin: 0 0 5px; color: #169b55; font-size: 15px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0 0 9px; font-size: clamp(28px, 4vw, 43px); }
.hero > p { max-width: 1100px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.5; }
.hero > .warning { margin-top: 6px; color: #c62828; font-weight: 800; }
.bulk-panel { display: grid; gap: 11px; margin-top: 22px; }
.bulk-copy p { margin: 5px 0 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
.bulk-label { font-size: 14px; }
#word-list {
  width: 100%;
  min-height: 92px;
  padding: 11px 12px;
  border: 1px solid #c8ced7;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  line-height: 1.45;
  resize: vertical;
}
#word-list:focus { border-color: #214bc7; outline: 3px solid rgba(33, 75, 199, .12); }
.bulk-actions { display: flex; align-items: center; gap: 14px; }
#bulk-status { color: var(--muted); font-size: 14px; }
.workspace { display: grid; gap: 22px; margin-top: 22px; }
.card-workspace { padding-bottom: 22px; border-bottom: 1px solid rgba(120, 126, 135, .28); }
.panel { padding: 24px 28px 28px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.editor-panel > .panel-head { justify-content: flex-end; }
h2 { margin: 0; font-size: 25px; }
h3 { margin: 22px 0 10px; font-size: 18px; }
.hint, #status { color: var(--muted); font-size: 14px; }
.hint { margin: 8px 0 16px; }
.button {
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid #214bc7;
  border-radius: 9px;
  background: #214bc7;
  color: #fff;
  font-weight: 800;
}
.button:hover { filter: brightness(.94); }
.button:disabled { cursor: wait; opacity: .55; }
.button.secondary { background: #fff; color: #214bc7; }
.line-editor { margin-top: 13px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fafbfc; }
.line-head { display: grid; grid-template-columns: minmax(260px, 1fr) 155px 155px auto; gap: 10px; align-items: end; }
label { color: #515c69; font-size: 13px; font-weight: 800; }
input[type="text"], input[type="number"] {
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  border: 1px solid #c8ced7;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.remove-line { min-height: 39px; border: 1px solid #e2b8b8; border-radius: 8px; background: #fff; color: #a22f2f; }
.letter-strip { display: flex; flex-wrap: wrap; gap: 4px; min-height: 47px; margin: 11px 0; padding: 7px; border: 1px dashed #c5cbd3; border-radius: 9px; background: #fff; }
.letter {
  display: inline-grid;
  place-items: center;
  min-width: 31px;
  height: 36px;
  padding: 0 5px;
  border: 2px solid transparent;
  border-radius: 7px;
  background: #edf0f4;
  color: #222;
  font-size: 20px;
  font-weight: 800;
  user-select: none;
}
.letter.space { min-width: 20px; color: #a4a9b0; font-size: 13px; }
.letter.selected { border-color: #171a1f; box-shadow: 0 0 0 2px #fff inset; }
.letter[data-tone="1"] { background: #ffd8d8; color: #e23b3f; }
.letter[data-tone="2"] { background: #d5f0df; color: #169b55; }
.letter[data-tone="3"] { background: #ffe1c6; color: #e98032; }
.letter[data-tone="4"] { background: #d6f2f7; color: #278ba1; }
.palette { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.palette span { margin-right: 2px; color: var(--muted); font-size: 13px; }
.tone {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #abb2bc;
}
.tone[data-tone="0"] { background: #24272c; }
.tone[data-tone="1"] { background: #e23b3f; }
.tone[data-tone="2"] { background: #169b55; }
.tone[data-tone="3"] { background: #e98032; }
.tone[data-tone="4"] { background: #55b8ce; }
.layout-controls { display: grid; grid-template-columns: repeat(3, minmax(180px, 250px)); gap: 12px; margin-top: 18px; }
.preview-scroll { width: 100%; margin-top: 8px; overflow-x: auto; border-radius: 8px; background: #eceef2; box-shadow: inset 0 0 0 1px #d4d8df; }
.preview-image { display: block; width: 1480px; height: 210px; background: #f1f2f4; object-fit: contain; }
.download-buttons { display: grid; grid-template-columns: repeat(5, 280px); gap: 20px; width: 1480px; }
.download { min-width: 108px; justify-self: center; }
.add-card-row { display: flex; justify-content: center; margin-top: 14px; }
.add-card { min-width: 190px; }
.all-download-panel { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 24px; }
#all-status { color: var(--muted); font-size: 14px; }

@media (max-width: 850px) {
  #card-app { width: min(100% - 18px, 1540px); padding-top: 10px; }
  .hero, .panel { border-radius: 12px; padding: 20px 16px; }
  .line-head, .layout-controls { grid-template-columns: 1fr 1fr; }
  .line-head label:first-child { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .panel-head { align-items: flex-start; flex-direction: column; }
  .line-head, .layout-controls { grid-template-columns: 1fr; }
  .line-head label:first-child { grid-column: auto; }
  .bulk-actions { align-items: stretch; flex-direction: column; }
}
