:root {
  color-scheme: light;
  --paper: #f7f3ea;
  --ink: #20201d;
  --muted: #686357;
  --line: #d8cebd;
  --panel: #fffaf1;
  --panel-deep: #efe5d2;
  --accent: #0f6b61;
  --accent-dark: #094f48;
  --warn: #b64b27;
  --shadow: 0 18px 50px rgba(56, 45, 28, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(32, 32, 29, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(32, 32, 29, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

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

.library-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.86);
  backdrop-filter: blur(16px);
}

.brand-block {
  display: grid;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-style: italic;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.05;
}

.summary-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.summary-line span {
  padding: 5px 9px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.search-box {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.search-box input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  background: #fffdf8;
  color: var(--ink);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 97, 0.16);
}

.tree-root {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding-right: 4px;
}

.date-group {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.76);
}

.date-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.date-toggle:hover {
  background: rgba(15, 107, 97, 0.08);
}

.date-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
}

.date-title::before {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid var(--accent);
  content: "";
  transform: rotate(90deg);
}

.date-group.is-collapsed .date-title::before {
  transform: rotate(0deg);
}

.date-count {
  color: var(--muted);
  font-size: 12px;
}

.card-list {
  display: grid;
  padding: 0 8px 8px;
}

.date-group.is-collapsed .card-list {
  display: none;
}

.card-row {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 54px;
  padding: 9px 10px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.card-row:hover,
.card-row.is-active {
  border-left-color: var(--warn);
  background: rgba(182, 75, 39, 0.08);
}

.card-row strong,
.card-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-row strong {
  font-size: 14px;
}

.card-row span {
  color: var(--muted);
  font-size: 12px;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 100vh;
  padding: 28px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.active-date {
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  font-style: italic;
}

.preview-header h2 {
  margin-top: 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  line-height: 1.12;
}

.active-path {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--accent-dark);
  background: var(--accent);
  color: white;
  text-decoration: none;
}

.open-link:hover {
  background: var(--accent-dark);
}

.open-link.is-disabled {
  pointer-events: none;
  border-color: var(--line);
  background: var(--panel-deep);
  color: var(--muted);
}

.card-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 640px;
  border: 1px solid var(--line);
  background: white;
  box-shadow: var(--shadow);
}

.empty-state {
  display: none;
  place-content: center;
  gap: 8px;
  min-height: 460px;
  border: 1px dashed var(--line);
  background: rgba(255, 250, 241, 0.8);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
}

.preview-panel.is-empty .empty-state {
  display: grid;
}

.preview-panel.is-empty .card-frame {
  display: none;
}

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

  .library-panel {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-panel {
    min-height: auto;
  }

  .preview-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .open-link {
    width: 100%;
  }

  .card-frame {
    min-height: 70vh;
  }
}
