:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #20231f;
  --muted: #676b62;
  --line: #d9ddd2;
  --line-strong: #b8c1ae;
  --accent: #0b7a75;
  --accent-strong: #075b57;
  --warn: #b95032;
  --ok: #28784a;
  --soft: #e9eee5;
  --focus: rgba(11, 122, 117, 0.18);
  font-family: "Yu Gothic UI", "Meiryo", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: #eef1eb;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #ffffff;
  font-weight: 700;
}

.brand strong,
.brand span,
.deploy-note strong,
.deploy-note span,
.deploy-note small {
  display: block;
}

.brand span,
.deploy-note small {
  color: var(--muted);
  margin-top: 4px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-list a {
  color: var(--ink);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
}

.nav-list a.active,
.nav-list a:hover {
  background: #dfe7db;
}

.deploy-note {
  margin-top: auto;
  border-top: 1px solid var(--line-strong);
  padding-top: 18px;
}

.workspace {
  padding: 28px;
  display: grid;
  gap: 24px;
}

.topbar,
.section-heading,
.action-row,
.pdf-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1,
.section-heading h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.25;
}

.section-heading h2 {
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

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

.secondary-button {
  background: var(--soft);
  color: var(--ink);
}

.ghost-button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
}

.status-strip div {
  padding: 18px;
  border-right: 1px solid var(--line);
}

.status-strip div:last-child {
  border-right: 0;
}

.status-strip span,
.stamp-log span,
.version-item span,
.source-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.grid-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 1fr;
  gap: 18px;
  align-items: start;
}

.document-list,
.editor-panel,
.preview-panel,
.version-area {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

#searchBox,
.edit-form input,
.edit-form textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
}

#searchBox {
  max-width: 220px;
}

.table-head,
.document-row {
  display: grid;
  grid-template-columns: 0.75fr 1.5fr 0.9fr 0.9fr;
  gap: 10px;
  align-items: center;
}

.table-head {
  margin-top: 18px;
  padding: 0 10px 10px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}

.table-body {
  display: grid;
}

.document-row {
  min-height: 62px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  transition: background 160ms ease;
}

.document-row:hover,
.document-row.selected {
  background: #eef5ef;
}

.document-row button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  padding: 0;
}

.state-pill {
  padding: 6px 10px;
  border-radius: 8px;
  background: #e7f2ed;
  color: var(--ok);
  font-size: 12px;
  font-weight: 700;
}

.state-pill.warning {
  background: #fae9e1;
  color: var(--warn);
}

.source-summary {
  margin: 18px 0;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.source-summary img {
  width: 84px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
}

.edit-form {
  display: grid;
  gap: 12px;
}

.edit-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.edit-form input:focus,
.edit-form textarea:focus,
#searchBox:focus {
  outline: 3px solid var(--focus);
  border-color: var(--accent);
}

.action-row {
  margin-top: 14px;
}

.pdf-preview {
  margin-top: 18px;
  min-height: 430px;
  padding: 30px;
  background: #fffdfa;
  border: 1px solid #d6d0c4;
  border-radius: 8px;
  box-shadow: 0 18px 36px rgba(32, 35, 31, 0.08);
}

.pdf-topline {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 14px;
  font-weight: 700;
}

.pdf-address {
  margin-top: 34px;
  font-size: 18px;
  font-weight: 700;
}

.pdf-subject {
  margin-top: 22px;
  padding: 12px 0;
  border-top: 1px solid #d6d0c4;
  border-bottom: 1px solid #d6d0c4;
}

.pdf-total {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 16px;
}

.pdf-total strong {
  font-size: 26px;
}

.pdf-lines {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  font-size: 14px;
}

.pdf-stamp {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px dashed #bdb6aa;
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
}

.pdf-stamp.done {
  color: var(--ok);
}

.stamp-log {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.stamp-log div,
.version-item {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.version-area {
  display: grid;
  gap: 18px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.version-item {
  min-height: 110px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.version-item strong {
  font-size: 15px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 340px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

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

  .preview-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip,
  .grid-layout,
  .timeline {
    grid-template-columns: 1fr;
  }

  .status-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .status-strip div:last-child {
    border-bottom: 0;
  }

  #searchBox {
    max-width: none;
  }

  .table-head,
  .document-row {
    grid-template-columns: 0.8fr 1.4fr;
  }

  .table-head span:nth-child(3),
  .table-head span:nth-child(4),
  .document-row span:nth-child(3),
  .document-row span:nth-child(4) {
    display: none;
  }
}
