:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --text: #202124;
  --muted: #73767c;
  --line: #e7e8eb;
  --accent: #eb7350;
  --accent-dark: #d95e3c;
  --green: #287d4d;
  --danger: #c34b4b;
  --shadow: 0 12px 35px rgba(27, 33, 43, .07);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", sans-serif; }
button, textarea, select { font: inherit; }
button { cursor: pointer; }
.shell { max-width: 1180px; margin: 0 auto; padding: 56px 24px 72px; }
.hero { display: flex; align-items: start; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.eyebrow, .step { margin: 0 0 7px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 4vw, 42px); line-height: 1.15; letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -.02em; }
.intro { max-width: 680px; margin-bottom: 0; color: var(--muted); font-size: 16px; }
code { padding: 1px 5px; border-radius: 4px; background: #f0e7e3; color: #a54a35; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font-size: 21px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.14fr); gap: 20px; }
.panel, .history-section { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.panel { padding: 26px; }
.panel-heading, .history-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.subtle, .result-summary { color: var(--muted); font-size: 13px; white-space: nowrap; }
textarea { display: block; width: 100%; min-height: 288px; resize: vertical; padding: 15px; border: 1px solid var(--line); border-radius: 12px; outline: none; background: var(--surface-soft); color: var(--text); line-height: 1.6; overflow-wrap: anywhere; word-break: break-all; white-space: pre-wrap; }
textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(235, 115, 80, .14); }
textarea::placeholder { color: #9ba0a8; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 17px 0; }
.check-label, .format-label { color: var(--muted); font-size: 13px; }
input[type="checkbox"] { width: 16px; height: 16px; vertical-align: -3px; accent-color: var(--accent); }
select { margin-left: 6px; padding: 7px 26px 7px 9px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: var(--surface); color: var(--text); font-size: 13px; }
.prefix-row { display: flex; align-items: center; gap: 10px; margin: -5px 0 17px; color: var(--muted); font-size: 13px; }
.prefix-row[hidden] { display: none; }
.prefix-row input { min-width: 0; flex: 1; height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: var(--surface); color: var(--text); }
.prefix-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(235, 115, 80, .14); }
.record-name-row { display: flex; align-items: center; gap: 10px; margin: -5px 0 17px; color: var(--muted); font-size: 13px; }
.record-name-row span { color: #a4a7ae; }
.record-name-row input { min-width: 0; flex: 1; height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: var(--surface); color: var(--text); }
.record-name-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(235, 115, 80, .14); }
.actions { display: flex; flex-wrap: wrap; gap: 9px; }
.button { min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; text-align: center; line-height: 40px; }
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-dark); }
.quiet { border-color: var(--line); background: var(--surface); color: var(--text); }
.quiet:hover { background: var(--surface-soft); }
.import-button { cursor: pointer; }
.empty-state { display: grid; min-height: 375px; place-content: center; justify-items: center; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.empty-state[hidden] { display: none; }
.empty-state p { max-width: 220px; margin: 0; }
.empty-mark { display: grid; width: 44px; height: 44px; place-items: center; margin-bottom: 12px; border-radius: 50%; background: #fff1ed; color: var(--accent); font-size: 24px; }
.results-toolbar { display: flex; gap: 18px; margin: -3px 0 14px; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--green); font-size: 13px; font-weight: 700; }
.text-button:hover { text-decoration: underline; }
.danger { color: var(--danger); }
.table-wrap { overflow: auto; max-height: 330px; border: 1px solid var(--line); border-radius: 11px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; background: var(--surface-soft); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:last-child td { border-bottom: 0; }
td:nth-child(1), td:nth-child(2) { white-space: nowrap; }
.result-link { display: block; max-width: 310px; overflow: hidden; color: var(--text); text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.result-link:hover { color: var(--accent); text-decoration: underline; }
.row-actions { display: flex; gap: 10px; }
.history-section { margin-top: 20px; padding: 24px 26px; }
.history-heading { margin-bottom: 14px; }
.history-list { display: grid; gap: 9px; }
.history-empty { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 14px; border-radius: 10px; background: var(--surface-soft); }
.history-title { margin: 0 0 2px; font-weight: 700; }
.history-meta { margin: 0; color: var(--muted); font-size: 12px; }
.history-badge { display: inline-block; margin-left: 7px; padding: 2px 6px; border-radius: 5px; background: #f0e7e3; color: #a54a35; font-size: 10px; font-weight: 800; letter-spacing: .03em; vertical-align: 1px; }
.history-actions { display: flex; gap: 13px; flex-shrink: 0; }
.toast { position: fixed; z-index: 10; right: 22px; bottom: 22px; max-width: calc(100vw - 44px); padding: 11px 15px; border-radius: 9px; background: #26272b; color: #fff; box-shadow: 0 8px 22px rgba(0, 0, 0, .2); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

body.dark { color-scheme: dark; --bg: #17181b; --surface: #202126; --surface-soft: #26282d; --text: #eeeeef; --muted: #a4a7ae; --line: #383b42; --shadow: none; }
body.dark code { background: #402c29; color: #ffb5a2; }
body.dark .empty-mark { background: #422b27; }
body.dark .history-badge { background: #402c29; color: #ffb5a2; }

@media (max-width: 820px) { .shell { padding: 32px 16px 48px; } .workspace { grid-template-columns: 1fr; } textarea { min-height: 220px; } .empty-state { min-height: 250px; } }
@media (max-width: 480px) { .hero { margin-bottom: 24px; } .panel, .history-section { padding: 20px; border-radius: 14px; } .settings-row, .prefix-row, .record-name-row { align-items: start; flex-direction: column; } .prefix-row, .record-name-row { gap: 6px; } .prefix-row input, .record-name-row input { width: 100%; } .result-link { max-width: 155px; } .history-item { align-items: start; flex-direction: column; gap: 8px; } }
