:root {
  --ink: #203e37;
  --muted: #67736b;
  --paper: #f6f5ef;
  --line: #d9ded5;
  --accent: #255f4e;
  --accent-light: #e6eee6;
  --warning: #805110;
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .6; }
button, input, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #ad631d; outline-offset: 4px; }
.page { width: min(1120px, calc(100% - 96px)); margin: 0 auto; padding: 44px 0 64px; }
.masthead { margin-bottom: 38px; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
#language { min-width: 0; max-width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; color: var(--ink); background: #fffefb; font-size: 13px; }
.wordmark { display: inline-flex; gap: 9px; align-items: center; font-size: 14px; font-weight: 700; letter-spacing: -.03em; }
.brand-mark { display: grid; grid-template-columns: repeat(2, 5px); gap: 3px; transform: rotate(-8deg); }
.brand-mark i { width: 5px; height: 5px; background: var(--accent); border-radius: 1px; }
.brand-mark i:last-child { background: #abbe8f; }
h1 { font-size: clamp(34px, 4vw, 48px); letter-spacing: -.065em; line-height: 1.2; margin: 34px 0 0; font-weight: 750; overflow-wrap: anywhere; }
h1 > b { color: #a2b889; padding-left: 3px; }
h2 { margin: 0; font-size: 18px; letter-spacing: -.04em; font-weight: 700; }
.workspace { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 50px; align-items: start; }
.workspace > * { min-width: 0; }
.input-panel { background: #fffefb; border: 1px solid var(--line); border-radius: 22px; padding: 25px; box-shadow: 0 8px 28px #213d3205; }
.panel-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; min-height: 34px; margin-bottom: 17px; }
.panel-heading > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.count { color: var(--accent); font-size: 13px; font-weight: 650; padding: 5px 11px; border-radius: 999px; background: var(--accent-light); }
textarea { display: block; width: 100%; border: 0; background: transparent; color: var(--ink); border-radius: 10px; font-size: 16px; line-height: 1.85; padding: 9px 12px; resize: vertical; }
#roster { min-height: 244px; max-height: 65vh; height: 270px; }
textarea::placeholder { color: #7b847b; }
.roster-wrap { background: #f7f8f3; border: 1px solid #e7e9e0; border-radius: 12px; }
.roster-wrap:focus-within { border-color: var(--accent); }
.input-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; margin: 4px 0 12px; gap: 4px 10px; }
.text-button { border: 0; background: transparent; color: var(--muted); text-decoration: underline; text-underline-offset: 4px; padding: 11px 3px; min-height: 44px; font-size: 13px; }
.text-button:hover { color: var(--accent); }
.local-label { color: var(--muted); font-size: 12px; }
.settings { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 5px 0 20px; }
.mode-switch { border: 0; padding: 0; margin: 0; display: flex; flex: 1 1 170px; min-width: 0; max-width: 100%; border-radius: 10px; background: #edf0e9; }
.mode-switch label { position: relative; display: flex; flex: 1; min-width: 0; cursor: pointer; }
.mode-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mode-switch span { flex: 1; min-width: 0; display: grid; place-items: center; min-height: 46px; padding: 9px 10px; margin: 3px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 600; text-align: center; overflow-wrap: anywhere; }
.mode-switch input:checked + span { color: var(--ink); background: #fffefb; box-shadow: 0 1px 4px #173c3610; }
.mode-switch input:focus-visible + span { outline: 3px solid #ad631d; outline-offset: 2px; }
.amount-field { display: flex; gap: 7px; align-items: center; max-width: 100%; }
.amount-field input { width: 83px; min-height: 49px; padding: 9px 6px 9px 12px; color: var(--ink); background: #fffefb; border: 1px solid var(--line); border-radius: 9px; font-size: 17px; font-variant-numeric: tabular-nums; }
.amount-field > span { min-width: 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.primary-button { width: 100%; min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px 16px; border: 0; border-radius: 12px; background: var(--accent); color: white; font-size: 16px; font-weight: 650; }
.primary-button:hover { background: #194937; }
.primary-button:active { transform: translateY(1px); }
.duplicate-notice { margin: 0 0 16px; border-radius: 10px; background: #fbf0d9; padding: 0 12px; color: var(--warning); font-size: 13px; }
.duplicate-notice summary { cursor: pointer; min-height: 44px; padding: 13px 0; overflow-wrap: anywhere; }
.duplicate-notice ul { list-style: none; margin: 0; padding: 0 0 10px; }
.duplicate-notice li { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; }
.duplicate-name { overflow-wrap: anywhere; max-width: 100%; font-weight: 600; }
.line-button { color: var(--warning); border: 1px solid #d6bd87; background: #fffaf0; padding: 9px; min-height: 44px; border-radius: 6px; }
.error { font-size: 13px; line-height: 1.65; color: #a32f24; margin: 0 0 15px; overflow-wrap: anywhere; }
.result-panel { padding-top: 10px; }
.result-heading { margin-bottom: 20px; min-height: 44px; }
#result-title > span { display: inline-block; margin-left: 9px; font-size: 13px; font-weight: 400; color: var(--muted); letter-spacing: normal; }
.copy-button { display: flex; align-items: center; justify-content: center; gap: 7px; background: #fffefb; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); font-size: 13px; padding: 10px 12px; min-height: 44px; }
.copy-button svg, .primary-button svg { flex-shrink: 0; }
.copy-button:hover { border-color: var(--accent); }
.groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.group-card { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #fffefb; min-width: 0; }
.group-card header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 8px; padding: 14px 17px; background: #e8eee3; }
.group-card header > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.group-card:nth-child(4n+2) header { background: #e8edf2; }
.group-card:nth-child(4n+3) header { background: #f3eade; }
.group-card:nth-child(4n+4) header { background: #efe8f0; }
.group-card h3 { margin: 0; font-size: 15px; }
.group-card header span { font-size: 12px; color: #4f6157; }
.group-card ul { list-style: none; padding: 14px 17px 17px; margin: 0; }
.group-card li { font-size: 15px; line-height: 1.7; padding: 4px 0; overflow-wrap: anywhere; }
.group-card small { display: inline-block; color: var(--muted); font-size: 11px; margin-left: 7px; }
.empty-result { display: grid; place-items: center; min-height: 394px; border: 1px dashed #d5dbce; border-radius: 20px; }
.empty-grid { display: flex; gap: 14px; opacity: .7; }
.empty-grid > div { width: 91px; height: 119px; border: 1px solid #d6dece; border-radius: 12px; padding: 24px 17px; background: #edf0e7; }
.empty-grid > div:nth-child(2) { transform: translateY(16px); background: #e9eee9; }
.empty-grid i { display: block; width: 100%; height: 5px; background: #cbd4c3; border-radius: 3px; margin-bottom: 12px; }
.empty-grid i:last-child { width: 68%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
dialog { width: min(500px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 18px; padding: 24px; background: #fffefb; color: var(--ink); }
dialog::backdrop { background: #173e375c; }
.dialog-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; overflow-wrap: anywhere; }
.copy-hint { font-size: 13px; color: var(--muted); }
#copy-text { margin: 14px 0; border: 1px solid var(--line); background: #f7f8f3; max-height: 50vh; }
@media (max-width: 980px) {
  .page { width: min(800px, calc(100% - 48px)); }
  .workspace { gap: 28px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .input-panel { padding: 21px; }
  .groups { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 699px) {
  .page { width: calc(100% - 36px); padding: 25px 0 42px; }
  .masthead { margin-bottom: 26px; }
  h1 { margin-top: 28px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .input-panel { padding: 20px; border-radius: 18px; }
  #roster { height: 222px; min-height: 190px; }
  .result-panel { padding-top: 0; }
  .empty-result { min-height: 180px; }
  .empty-grid { transform: scale(.75); }
  .groups { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .group-card header { padding: 12px; }
  .group-card ul { padding: 10px 12px 14px; }
  .result-heading { gap: 8px; }
  .result-heading h2 { font-size: 17px; }
  #result-title > span { display: block; margin: 4px 0 0; }
}
@media (max-width: 359px) {
  .groups { grid-template-columns: minmax(0, 1fr); }
  .mode-switch { flex-basis: 100%; }
}
