:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --ink: #202124;
  --muted: #6a6f73;
  --line: #d9d6ce;
  --panel: #ffffff;
  --accent: #166b5d;
  --accent-strong: #0f4d43;
  --danger: #a23a35;
  --shadow: 0 16px 45px rgba(31, 35, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

button:hover {
  border-color: #9aa19e;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-strong);
}

button.ghost {
  background: transparent;
}

button.danger,
.danger {
  color: var(--danger);
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px 18px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.1;
}

h2 {
  font-size: 15px;
}

.actions {
  display: flex;
  gap: 10px;
}

.workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.15fr) minmax(250px, 0.7fr);
  padding: 0 32px 32px;
}

.pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 580px;
  overflow: hidden;
}

.pane-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 54px;
  padding: 12px 16px;
}

.hint,
.state {
  color: var(--muted);
  font-size: 13px;
}

textarea {
  border: 0;
  color: var(--ink);
  display: block;
  height: calc(100% - 54px);
  line-height: 1.8;
  min-height: 526px;
  outline: none;
  padding: 18px;
  resize: none;
  width: 100%;
}

.preview {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  font-size: 19px;
  line-height: 2.25;
  min-height: 526px;
  overflow: auto;
  padding: 20px 22px;
  white-space: pre-wrap;
}

.preview ruby {
  line-height: 1;
  margin: 0 0.02em;
  ruby-align: center;
  ruby-position: over;
}

.preview rb {
  text-align: center;
}

.preview rt {
  line-height: 1;
}

.ruby-input {
  background: #f7fbfa;
  border: 1px solid #c8d8d4;
  border-radius: 4px;
  color: var(--accent-strong);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 11px;
  height: 18px;
  min-width: 1.6em;
  padding: 0 3px;
  text-align: center;
  width: var(--ruby-input-width, 2em);
}

.ruby-input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(22, 107, 93, 0.15);
}

.docs-list {
  display: grid;
  gap: 10px;
  max-height: 526px;
  overflow: auto;
  padding: 14px;
}

.empty {
  color: var(--muted);
  line-height: 1.7;
  padding: 18px 4px;
}

.doc-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.doc-title {
  border: 0;
  border-radius: 0;
  font-weight: 700;
  justify-content: flex-start;
  min-height: auto;
  overflow-wrap: anywhere;
  padding: 0;
  text-align: left;
}

.doc-item time {
  color: var(--muted);
  font-size: 12px;
}

.doc-actions {
  display: flex;
  gap: 8px;
}

.doc-actions button {
  flex: 1;
  min-height: 34px;
  padding: 0 8px;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .library-pane {
    grid-column: 1 / -1;
    min-height: 260px;
  }

  .docs-list {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px 18px 16px;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 0 18px 24px;
  }

  .pane {
    min-height: 420px;
  }

  textarea,
  .preview {
    min-height: 366px;
  }
}
