:root {
  color-scheme: light;
  --bg: #f6f2ea;
  --panel: #fffdf8;
  --ink: #273238;
  --muted: #6b7477;
  --line: #ddd5c7;
  --accent: #2d7d7a;
  --accent-strong: #215f5d;
  --sun: #f4b942;
  --rose: #d86f63;
  --shadow: 0 18px 45px rgba(45, 54, 58, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
a {
  font: inherit;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
}

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

.progress-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.progress-copy strong {
  color: var(--accent-strong);
  font-size: 18px;
}

.progress-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #ece5d8;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--sun));
  transition: width 180ms ease;
}

.day-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.day-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.day-button:hover,
.day-button.active {
  border-color: var(--accent);
}

.day-button.active {
  background: #eef8f6;
}

.day-button.done::after {
  content: "✓";
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.reader {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
  gap: 16px;
}

.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.reader-header h2 {
  margin: 0;
  font-size: 28px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.preview-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.icon-button {
  width: 40px;
  font-size: 20px;
}

.preview-button {
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 12px 16px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.complete-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.complete-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

#imageHint {
  color: var(--muted);
  font-size: 14px;
}

.image-stage {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.image-stage img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 320px;
  object-fit: contain;
}

.preview-open {
  overflow: hidden;
}

.preview {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  padding: 18px;
  background: rgba(18, 24, 28, 0.72);
}

.preview[aria-hidden="false"] {
  display: grid;
  place-items: center;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1180px, 100%);
  height: min(92vh, 900px);
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
}

.preview-header,
.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.preview-header h2 {
  margin: 0;
  font-size: 18px;
}

.preview-close {
  flex: 0 0 auto;
}

.preview-body {
  display: grid;
  place-items: center;
  overflow: auto;
  background: #f7f3ea;
}

.preview-body img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 1400px;
  max-height: 100%;
  margin: 0 auto;
  object-fit: contain;
}

.preview-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.preview-nav {
  min-height: 44px;
  min-width: 120px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-weight: 700;
}

.preview-nav:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

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

  .day-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    max-height: 156px;
  }

  .reader {
    padding: 18px;
  }

  .reader-header,
  .status-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    width: 100%;
  }

  .preview-button {
    flex: 1;
  }

  .image-stage {
    overflow: visible;
  }
}

@media (max-width: 520px) {
  .sidebar {
    padding: 18px;
  }

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

  .day-button {
    min-height: 42px;
    padding: 8px 10px;
  }

  .preview {
    padding: 0;
  }

  .preview-panel {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }

  .preview-header,
  .preview-footer {
    padding: 10px;
  }

  .preview-body {
    padding: 8px;
    overflow: hidden;
  }

  .preview-body img {
    width: 100%;
    height: 100%;
    min-width: 0;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }

  .preview-nav {
    flex: 1;
    min-width: 0;
  }
}
