:root {
  --paper: #f3efe4;
  --ink: #1e1a16;
  --muted: #6d645a;
  --rust: #a33b24;
  --rust-dark: #7c2b1a;
  --card: #fffdf8;
  --line: #ddd4c4;
  --moss: #2f4a32;
  --shadow: 0 16px 40px rgba(48, 32, 18, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(163, 59, 36, 0.08), transparent 32rem),
    var(--paper);
  color: var(--ink);
  font: 16px/1.5 "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; color: inherit; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.4rem;
  background: var(--ink);
  color: #f6f1e7;
}

.brand { display: flex; gap: 0.8rem; align-items: center; }
.brand span { display: block; color: #c8bfb2; font-size: 0.85rem; }
.seal {
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border: 1px solid #c8bfb2;
  border-radius: 0.4rem;
  letter-spacing: 0.04em;
  font-family: Palatino, Georgia, serif;
}

main { padding: 1.2rem; }

.panel {
  width: min(460px, 100%);
  margin: 6vh auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 1.4rem;
}

h1, h2, h3 { font-family: Palatino, Georgia, serif; font-weight: 600; margin: 0 0 0.6rem; }
h1 { font-size: 2rem; }

.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.tabs button, .ghost, .primary, .danger {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}
.tabs button.active, .primary { background: var(--rust); color: white; border-color: var(--rust); }
.danger { color: var(--rust-dark); }
.ghost { background: var(--card); }

label { display: block; margin: 0.7rem 0; }
label span, .hint { display: block; color: var(--muted); font-size: 0.85rem; margin-bottom: 0.25rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 0.6rem;
  padding: 0.55rem 0.7rem;
}
textarea { min-height: 55vh; resize: vertical; font-family: Consolas, "Courier New", monospace; line-height: 1.45; }
.warn { color: var(--rust-dark); font-size: 0.9rem; }
.ok { color: var(--moss); }

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  align-items: start;
}
.side, .editor {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.9rem;
}
.side { max-height: calc(100vh - 6.5rem); overflow: auto; }
.row { display: flex; gap: 0.4rem; align-items: center; }
.row > * { flex: 1; }
.item {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0.6rem;
  background: transparent;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
}
.item.active, .item:hover { background: #f6efe4; }
.meta { color: var(--muted); font-size: 0.8rem; word-break: break-all; }
.version { border-top: 1px solid var(--line); padding: 0.6rem 0; }
.version pre { white-space: pre-wrap; max-height: 7rem; overflow: auto; background: #f7f3ea; padding: 0.5rem; border-radius: 0.4rem; }
.error { color: var(--rust-dark); min-height: 1.2rem; }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  textarea { min-height: 40vh; }
}
