/* Memory Calendar studio: top bar, month rail, month editor, post timeline, preview. Uses site.css tokens. */

.studio-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
}

.topbar .brand {
  margin-right: 0;
}

.topbar .logo {
  display: block;
  width: auto;
  height: 32px;
  border-radius: 6px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.field {
  display: grid;
  gap: 2px;
}

.field span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.field select,
.tl-add {
  appearance: none;
  padding: 6px 30px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23887e70' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center / 10px;
  color: var(--ink);
  font: 600 0.88rem var(--text);
  cursor: pointer;
}

.top-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.sample-note {
  margin: 0;
  padding: 10px 20px;
  background: var(--accent-soft);
  font-size: 0.9rem;
  text-align: center;
}

.sample-note a {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- layout ---------- */

.studio {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
}

.hello {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.hello-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.hello-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.hello-status {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.link-btn {
  margin-left: auto;
  padding: 6px 4px;
  border: 0;
  background: none;
  color: var(--accent);
  font: 700 0.92rem var(--text);
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

/* ---------- month rail ---------- */

.rail ol {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.rail-month {
  display: grid;
  justify-items: center;
  gap: 3px;
  width: 100%;
  padding: 6px 6px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.rail-month:hover {
  border-color: var(--ink);
}

.rail-month[aria-current='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.rail-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: var(--sunk);
}

.rail-month.is-empty .rail-thumb {
  border: 1.5px dashed var(--line);
  background: transparent;
}

.rail-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rail-thumb--text {
  display: grid;
  align-items: center;
  padding: 6px;
  background: var(--accent-soft);
  font: 600 0.72rem/1.25 var(--display);
  overflow-wrap: anywhere;
}

.rail-thumb--text span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.rail-name {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.1;
}

.rail-year {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
}

.rail-dots {
  display: flex;
  gap: 3px;
}

.rail-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line);
}

.rail-dots i.is-on {
  background: var(--accent);
}

/* ---------- workspace ---------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  align-items: start;
  gap: 20px;
}

.editor,
.timeline {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.editor {
  padding: 18px;
}

.editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.editor-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.15;
}

.editor-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.editor-page {
  max-width: 500px;
  margin: 18px auto;
}

.editor-page--desk {
  max-width: 680px;
}

.slots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.slot-label {
  display: grid;
  gap: 4px;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.25;
}

.slot-soft {
  color: var(--accent);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 600;
}

.slot-soft:empty {
  display: none;
}

.slot-tools {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font: 700 1rem/1 var(--text);
  cursor: pointer;
}

.icon-btn:hover:not(:disabled) {
  border-color: var(--ink);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.icon-btn--remove:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- timeline ---------- */

.timeline {
  position: sticky;
  top: 86px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 106px);
  overflow: hidden;
}

.timeline-head {
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.timeline-title {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--sunk);
}

.seg button {
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 700 0.82rem var(--text);
  cursor: pointer;
}

.seg button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}

.timeline-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.timeline-body {
  overflow-y: auto;
  padding: 0 16px 16px;
  overscroll-behavior: contain;
}

.tl-label {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 12px 0 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.timeline-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.timeline-filters input {
  flex: 1 1 145px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
}

.timeline-filters .tl-add {
  flex: 0 1 auto;
  width: auto;
}

.day-filter {
  margin-top: 8px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--ink);
  font: 700 0.8rem var(--text);
  cursor: pointer;
}

.tl-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tl-item {
  display: grid;
  justify-items: start;
  gap: 5px;
}

.tl-post {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tl-post:hover {
  border-color: var(--accent);
}

.tl-post[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tl-post img {
  flex: 0 0 60px;
  width: 60px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
}

.tl-copy {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 3px;
  overflow-wrap: anywhere;
}

.tl-date {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.tl-place {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.tl-text {
  display: -webkit-box;
  overflow: hidden;
  font: 500 0.95rem/1.35 var(--display);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.tl-badge {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--sunk);
  color: var(--ink);
}

.tl-post[aria-pressed='true'] .tl-badge {
  background: var(--accent);
  color: var(--on-accent);
}

.tl-badge:empty {
  display: none;
}

.tl-item > .tl-add {
  width: auto;
  max-width: 100%;
  justify-self: end;
}

.tl-add {
  width: 100%;
  padding: 4px 24px 4px 8px;
  background-position: right 8px center;
  font-size: 0.75rem;
}

/* ---------- preview ---------- */

.preview {
  flex: 1;
}

.preview-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
}

.preview-info {
  flex: 1;
  min-width: 200px;
}

.preview-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
}

.preview-info p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.preview-pages {
  display: grid;
  justify-items: center;
  gap: 32px;
  padding: 32px 20px 56px;
}

.preview-pages .page-fit {
  max-width: 560px;
}

.preview-pages--desk .page-fit {
  max-width: 760px;
}

/* ---------- loading and messages ---------- */

.state {
  display: grid;
  flex: 1;
  place-content: center;
  justify-items: center;
  gap: 8px;
  min-height: 60vh;
  padding: 40px 20px;
  text-align: center;
}

.state-title {
  margin: 8px 0 0;
  font-family: var(--display);
  font-size: 1.8rem;
  font-weight: 600;
}

.state-text {
  max-width: 30em;
  margin: 0;
  color: var(--muted);
}

.state-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

.studio-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  padding: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.studio-foot a {
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }

  .toast {
    transition: none;
  }
}

/* ---------- narrower screens ---------- */

@media (max-width: 1100px) {
  .rail ol {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 78px;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
  }

  .rail li {
    scroll-snap-align: start;
  }
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .timeline {
    position: static;
    max-height: none;
  }

  .timeline-body {
    max-height: 70vh;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 10px 16px;
  }

  .top-actions {
    margin-left: 0;
    width: 100%;
  }

  .top-actions .btn {
    flex: 1;
  }

  .controls {
    order: 3;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .field select {
    width: 100%;
  }

  .studio {
    padding: 16px;
  }

  .editor {
    padding: 14px;
  }

  .hello {
    flex-wrap: wrap;
  }

  .link-btn {
    margin-left: 0;
  }

}
