:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-soft: #f0f3ec;
  --text: #1f2a24;
  --muted: #657168;
  --line: #dce2d8;
  --accent: #2f6f4e;
  --accent-dark: #24573d;
  --danger: #a33a2a;
  --shadow: 0 12px 28px rgba(31, 42, 36, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 10px 14px;
}

button:hover {
  background: var(--accent-dark);
}

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

button.ghost:hover {
  background: var(--panel-soft);
}

button.danger {
  border-color: #e2bbb4;
  color: var(--danger);
}

button.danger:hover {
  background: #fff0ed;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel h1,
.sidebar h1,
.editor h2,
.create-box h2,
.draft-list-header h2,
.panel-header h2 {
  margin: 0;
}

.workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 18px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 20px;
}

.sidebar-header,
.draft-list-header,
.editor-topbar,
.panel-header,
.sheet-header,
.image-row,
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wrap {
  flex-wrap: wrap;
}

.sidebar-header,
.draft-list-header,
.editor-topbar,
.panel-header,
.sheet-header {
  justify-content: space-between;
}

#current-user,
.eyebrow {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.create-box,
.days-panel,
.editor-form,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.create-box {
  display: grid;
  gap: 12px;
}

.draft-tree {
  display: grid;
  gap: 2px;
}

.tree-node {
  display: grid;
}

.tree-children {
  display: grid;
}

.tree-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: stretch;
  padding-left: calc(var(--depth) * 18px);
}

.tree-item {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-weight: 600;
}

.tree-item:hover {
  background: var(--panel-soft);
}

.tree-item.folder-active {
  border-color: #bed2c2;
  background: #eef7ef;
}

.tree-item.active {
  border-color: var(--accent);
  background: #e3f2e8;
}

.tree-icon {
  display: inline-grid;
  place-items: start center;
  padding-top: 9px;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.5;
}

.tree-disclosure {
  display: inline-grid;
  place-items: center;
  width: 22px;
  min-height: 42px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
  font-weight: 700;
}

.tree-disclosure:not(.empty):hover {
  background: #d9eadc;
}

.tree-disclosure.empty:hover {
  background: transparent;
}

.tree-disclosure.empty {
  color: #a6b3aa;
}

.tree-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 24px;
}

.editor-form,
.day-form {
  display: grid;
  gap: 16px;
}

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

.messages {
  display: grid;
  gap: 8px;
}

.message {
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel-soft);
  color: var(--text);
}

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

.image-status {
  color: var(--muted);
  font-size: 13px;
}

.image-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.image-preview-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.image-preview-row figure {
  display: grid;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.image-preview-row img {
  width: 180px;
  height: 110px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.image-preview-row .icon-preview img {
  width: 88px;
  height: 88px;
}

.image-picker {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(31, 42, 36, 0.35);
  padding: 22px;
}

.image-picker-panel {
  width: min(820px, 100%);
  max-height: min(720px, 90vh);
  overflow: auto;
  display: grid;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.global-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.global-image-grid button {
  display: grid;
  gap: 8px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
}

.global-image-grid button:hover {
  background: var(--panel-soft);
}

.global-image-grid img {
  width: 100%;
  aspect-ratio: 1.35;
  object-fit: cover;
  border-radius: 6px;
  background: var(--panel-soft);
}

.content-mode {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.field-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

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

.version-item {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

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

.days-panel {
  display: grid;
  gap: 14px;
}

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

.day-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.day-item button {
  flex: none;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(31, 42, 36, 0.28);
}

.day-sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(560px, calc(100vw - 32px));
  overflow: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px rgba(31, 42, 36, 0.16);
  padding: 22px;
}

.sheet-header h3 {
  margin: 0;
}

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

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

  .grid.two,
  .image-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .editor-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .day-sheet {
    inset: 0;
    width: 100vw;
    border-left: 0;
  }
}
