:root {
  --bg: #0e1512;
  --bg-panel: #141d19;
  --bg-raised: #1a2420;
  --paper: #e7e2d3;
  --ink: #11150f;
  --accent: #c99a3d;
  --accent-dim: #8a7139;
  --signal: #5e9a82;
  --line: #2b3833;
  --line-soft: #222c27;
  --text: #d8d4c3;
  --text-dim: #8c9490;
  --danger: #b0563f;
  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  margin: 0;
}

body {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  color: var(--text);
  background-image: repeating-linear-gradient(0deg, transparent, transparent 39px, var(--line-soft) 39px, var(--line-soft) 40px);
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 18px 64px;
}

.masthead {
  border-bottom: 3px double var(--line);
  padding-bottom: 14px;
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.masthead .title {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 700;
  font-size: clamp(28px, 7vw, 40px);
  color: var(--text);
  line-height: 1;
}
.masthead .sub {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 6px;
}
.app-lang-select {
  font-family: inherit;
  font-size: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 8px;
  flex: none;
  margin-top: 4px;
}

.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.section-num {
  font-size: 11px; color: var(--accent);
  border: 1px solid var(--line);
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; flex: none;
}
.section-title { font-family: Georgia, serif; font-weight: 600; font-size: 18px; color: var(--text); }
.section-hint { font-size: 11.5px; color: var(--text-dim); margin: -2px 0 12px 30px; line-height: 1.5; }

.text-input {
  font-family: inherit;
  font-size: 13px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
}
.text-input:focus { outline: none; border-color: var(--accent-dim); }
.text-input::placeholder { color: var(--text-dim); }

.topics { display: flex; flex-wrap: wrap; gap: 8px; margin-left: 30px; }
.chip {
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 9px 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; }
.chip[aria-pressed="true"] { border-color: var(--signal); background: var(--bg-raised); }
.chip[aria-pressed="true"] .dot { background: var(--signal); box-shadow: 0 0 0 3px rgba(94,154,130,0.2); }
.chip.custom { border-style: dashed; color: var(--text-dim); }
.chip .rm { color: var(--text-dim); font-size: 14px; margin-left: 2px; }
.chip .rm:hover { color: var(--danger); }

.add-topic { margin-left: 30px; margin-top: 10px; display: flex; gap: 8px; }
.add-topic input {
  flex: 1; font-family: inherit; font-size: 13px; background: transparent;
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 9px 11px; color: var(--text); min-width: 0;
}
.add-topic input::placeholder { color: var(--text-dim); }
.add-topic button {
  font-family: inherit; font-size: 12px; background: transparent;
  border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text-dim); padding: 0 14px; cursor: pointer;
}
.add-topic button:hover { border-color: var(--accent-dim); color: var(--accent); }

.seg { margin-left: 30px; display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button {
  flex: 1; font-family: inherit; font-size: 12.5px; color: var(--text-dim);
  background: var(--bg-panel); border: none; border-right: 1px solid var(--line);
  padding: 12px 6px; cursor: pointer; text-align: center; line-height: 1.4;
}
.seg button:last-child { border-right: none; }
.seg button b { display: block; font-size: 13.5px; margin-bottom: 2px; }
.seg button small { display: block; font-size: 10px; opacity: .8; }
.seg button[aria-pressed="true"] { background: var(--bg-raised); color: var(--accent); }
.seg button[aria-pressed="true"] b { color: var(--text); }
.seg button.locked { opacity: 0.55; cursor: pointer; }
.seg button.locked:hover { opacity: 0.8; }
.plan-badge { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 7px; border-radius: var(--radius); border: 1px solid var(--line); color: var(--text-dim); }
.plan-badge.plus { color: var(--accent); border-color: var(--accent-dim); }
.lock-badge { font-size: 10px; margin-right: 2px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 360px;
  width: 100%;
}
.modal-title {
  font-family: Georgia, serif;
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
  margin-bottom: 8px;
}
.modal-message {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.output { margin-top: 30px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-panel); }
.output-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.output-head .lbl { font-size: 10.5px; letter-spacing: 0.12em; color: var(--text-dim); text-transform: uppercase; }
.led { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); }
.led.ok { background: var(--signal); box-shadow: 0 0 0 3px rgba(94,154,130,0.2); }
.led.err { background: var(--danger); box-shadow: 0 0 0 3px rgba(176,86,63,0.2); }

.status-box { padding: 14px; font-size: 12.5px; line-height: 1.6; color: var(--text-dim); }

.actions { display: flex; gap: 10px; padding: 0 14px 14px; flex-wrap: wrap; }
.btn {
  font-family: inherit; font-size: 12.5px; border-radius: var(--radius);
  padding: 10px 16px; cursor: pointer; border: 1px solid var(--line);
  background: transparent; color: var(--text);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #14100a; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }

.save-note { font-size: 11px; color: var(--text-dim); padding: 0 14px 14px; min-height: 14px; }
.save-note.ok { color: var(--signal); }
.save-note.err { color: var(--danger); }

footer {
  margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 10.5px; color: var(--text-dim); line-height: 1.7;
}
footer code { color: var(--accent); }

@media (max-width: 420px) {
  .seg { flex-direction: column; }
  .seg button { border-right: none; border-bottom: 1px solid var(--line); }
  .seg button:last-child { border-bottom: none; }
}
