/* Screen parts: header, tab bar, composer, entry cards, calendar, login, and Hiyorin. */

.page-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-top: var(--space-6);
}

.page-header-text {
  flex: 1;
  min-width: 0;
}

.page-header-meta {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  justify-content: space-between;
}

.page-header-aside {
  margin: 0 0 0 auto;
  color: var(--color-muted);
  white-space: nowrap;
}

.page-header h1,
.page-title {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: 800;
}

.page-title {
  padding-top: var(--space-6);
}

.eyebrow {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

/* Fixed to the bottom, where a thumb reaches; links, so it works without JavaScript. */
.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: var(--tabbar-height);
  /* The bar spans the screen, but the tabs line up with the content column on wide screens */
  padding: var(--space-1) max(var(--space-2), (100% - var(--content-max)) / 2) env(safe-area-inset-bottom);
  border-top: 1px solid var(--color-day-0);
  background: var(--color-surface);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: var(--control-height);
  color: var(--color-muted);
  font-size: var(--font-size-xs);
  line-height: 1.2;
  text-decoration: none;
}

.tab[aria-current="page"] {
  color: var(--color-primary);
  font-weight: 800;
}

.composer {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.composer .button {
  margin-bottom: 0;
}

.composer textarea {
  margin-top: var(--space-2);
  background: var(--color-paper);
}

/* Only the "変える" pill opens the picker; a tap elsewhere on the row should not. */
.time summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--control-height);
  list-style: none;
  pointer-events: none;
}

.time-value {
  pointer-events: auto;
  cursor: pointer;
}

.time summary::-webkit-details-marker {
  display: none;
}

.time-label {
  font-weight: 700;
}

.time-value {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  padding: 0 var(--space-3);
  border-radius: var(--radius);
  background: var(--color-soft);
  font-size: var(--font-size-md);
  font-weight: 700;
}

.time-change {
  color: var(--color-link);
  font-size: var(--font-size-sm);
  font-weight: 400;
  text-decoration: underline;
}

.time[open] .time-value {
  display: none;
}

.day {
  margin-top: var(--space-6);
}

.day-title {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  font-size: var(--font-size-md);
  font-weight: 800;
}

.day-count {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
  font-weight: 400;
}

.entries {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.entry {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.entry-saved {
  animation: entry-saved-fade 2.4s ease-in 0.6s both;
}

@keyframes entry-saved-fade {
  from {
    background: var(--color-saved-bg);
  }
  to {
    background: var(--color-surface);
  }
}

.entry-time {
  flex: none;
  min-width: 3rem;
  color: var(--color-muted);
  font-weight: 700;
}

.entry-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}

.entry-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.entry-url {
  color: var(--color-url);
}

.link-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
}

.link-preview[hidden] {
  display: none;
}

.link-preview-site,
.link-preview-description {
  color: var(--color-muted);
  font-size: var(--font-size-xs);
}

.link-preview-title {
  color: var(--color-url);
  font-weight: 700;
  text-decoration: underline;
}

.link-preview-site:empty,
.link-preview-description:empty {
  display: none;
}

.entry-edit {
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: var(--control-height);
  margin: calc(-1 * var(--space-3)) 0;
}

.empty {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-muted);
}

.empty p {
  margin: 0;
}

.calendar {
  margin-top: var(--space-6);
  padding: var(--space-3) var(--space-2) var(--space-4);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.month-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-2);
}

.month-bar h2 {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 800;
}

.round-button,
.round-button-space {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height);
  height: var(--control-height);
  border-radius: 50%;
}

.round-button {
  background: var(--color-soft);
  color: var(--color-primary);
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  row-gap: var(--space-1);
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin: var(--space-3) 0 0;
  color: var(--color-muted);
  font-size: var(--font-size-xs);
  text-align: center;
}

.day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: var(--control-height);
  padding: var(--space-1) 0;
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
}

.day-disc {
  fill: var(--color-day-0);
  stroke: transparent;
  stroke-width: 2.5;
}

.level-1 .day-disc,
.dot.level-1 {
  fill: var(--color-day-1);
  background: var(--color-day-1);
}

.level-2 .day-disc,
.dot.level-2 {
  fill: var(--color-day-2);
  background: var(--color-day-2);
}

.level-3 .day-disc,
.dot.level-3 {
  fill: var(--color-day-3);
  background: var(--color-day-3);
}

.day-cell[aria-current="date"] .day-disc {
  stroke: var(--color-primary);
}

.day-colors {
  display: flex;
  gap: 2px;
  min-height: 0.5rem;
}

.day-colors .swatch {
  width: 0.5rem;
  height: 0.5rem;
  box-shadow: none;
}

.day-number {
  padding: 0 var(--space-2);
  border-radius: 999px;
  color: var(--color-muted);
  font-size: var(--font-size-xs);
  line-height: 1.5;
}

.is-today .day-number {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  font-weight: 700;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-3) var(--space-2) 0;
  color: var(--color-muted);
  font-size: var(--font-size-xs);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.dot {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
}

body.login {
  background: var(--color-hero);
}

/* The page sits on the green like a sheet pulled up over it. */
.login main {
  min-height: 70dvh;
  padding-top: var(--space-4);
  border-radius: 2rem 2rem 0 0;
  background: var(--color-bg);
}

.login-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-4) var(--space-6);
  text-align: center;
}

.login-hero h1 {
  margin: 0;
  font-size: var(--font-size-hero);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.login-hero p {
  margin: 0;
}

.uses {
  margin-top: var(--space-8);
}

.uses h2 {
  margin: 0 0 var(--space-4);
  font-size: var(--font-size-md);
  text-align: center;
}

.use-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.use {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.use-voice {
  position: relative;
  flex: 1;
  margin: 0;
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--label-bg);
  font-size: var(--font-size-xs);
  line-height: 1.6;
}

/* The bubble's tail, pointing down at who is speaking. */
.use-voice::after {
  content: "";
  position: absolute;
  bottom: -0.5rem;
  left: var(--space-4);
  border: 0.5rem solid transparent;
  border-top-color: var(--label-bg);
  border-bottom: 0;
}

.use-name {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0 0 0 var(--space-2);
  color: var(--color-muted);
  font-size: var(--font-size-xs);
  font-weight: 700;
}

.use-name::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--label-dot);
}

.login-title {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-studio {
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.16em;
}

.code-input {
  font-size: var(--font-size-xl);
  letter-spacing: 0.4em;
  text-align: center;
}

.mascot .mascot-body {
  fill: var(--color-leaf);
}

.mascot-spine,
.mascot-leaf {
  fill: var(--color-leaf-dark);
}

.mascot-sprout {
  fill: var(--color-sprout);
}

.mascot-ribbon {
  fill: var(--color-ribbon);
}

.mascot-paper,
.mascot-flower {
  fill: var(--color-paper);
}

.mascot-flower {
  stroke: var(--color-ribbon);
}

.mascot-ink {
  fill: var(--color-ink);
}

.mascot-shine {
  fill: var(--color-surface);
}

.mascot-cheek {
  fill: var(--color-cheek);
}

.mascot-line,
.mascot-arm {
  fill: none;
  stroke-linecap: round;
}

.mascot-line {
  stroke: var(--color-ink);
}

.mascot-arm {
  stroke: var(--color-leaf-dark);
}

.mascot {
  flex: none;
}

/* Error pages: a sheet card with Hiyorin standing in for the middle digit. */
.error-page {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  margin-top: var(--space-8);
  padding: var(--space-8) var(--space-6);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.error-page h1 {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: 800;
}

.error-page .lead {
  margin: 0 0 var(--space-2);
  color: var(--color-muted);
}

.error-code {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  color: var(--color-leaf-dark);
  font-size: 4.5rem;
  font-weight: 800;
  line-height: 1;
}

/*
 * Seasonal shapes drifting over the tinted top of the write screen (SeasonDecor.tsx). The CSP
 * forbids inline styles, so each shape's place, size and pace come from nth-child here. Only
 * transform and opacity animate, to stay cheap on phones.
 */
body[class*="season-"] {
  position: relative;
  isolation: isolate;
}

.season-decor {
  position: absolute;
  z-index: -1;
  top: 0;
  right: 0;
  left: 0;
  height: 18rem;
  overflow: hidden;
  pointer-events: none;
}

.season-decor-spring {
  color: #f0a3bd;
}
.season-decor-summer {
  color: #e8a317;
}
.season-decor-autumn {
  color: #e0763a;
}
.season-decor-winter {
  color: #8fb0d0;
}

.season-p {
  position: absolute;
  top: -1.5rem;
  width: 1.25rem;
  height: 1.25rem;
  opacity: 0.8;
  animation: season-fall 11s linear infinite;
}

.season-p svg {
  display: block;
  width: 100%;
  height: 100%;
}

.season-p:nth-child(1) {
  left: 6%;
  animation-delay: -1s;
}
.season-p:nth-child(2) {
  left: 22%;
  width: 1.5rem;
  height: 1.5rem;
  animation-duration: 13s;
  animation-delay: -7s;
}
.season-p:nth-child(3) {
  left: 38%;
  animation-duration: 9s;
  animation-delay: -4s;
}
.season-p:nth-child(4) {
  left: 55%;
  width: 1rem;
  height: 1rem;
  animation-duration: 12s;
  animation-delay: -10s;
}
.season-p:nth-child(5) {
  left: 70%;
  width: 1.5rem;
  height: 1.5rem;
  animation-delay: -2.5s;
}
.season-p:nth-child(6) {
  left: 84%;
  animation-duration: 10s;
  animation-delay: -6s;
}
.season-p:nth-child(7) {
  left: 94%;
  width: 1rem;
  height: 1rem;
  animation-duration: 14s;
  animation-delay: -12s;
}

/* Fireworks sparkle in place instead of falling; each sits at its own height. */
.season-decor-summer .season-p {
  top: calc(var(--space-6) + 1.5rem * var(--row, 0));
  animation-name: season-twinkle;
  animation-duration: 3.5s;
  animation-timing-function: ease-in-out;
}
.season-decor-summer .season-p:nth-child(odd) {
  --row: 2;
}
.season-decor-summer .season-p:nth-child(3n) {
  --row: 5;
}

@keyframes season-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  10%,
  70% {
    opacity: 0.8;
  }
  100% {
    transform: translateY(18rem) rotate(260deg);
    opacity: 0;
  }
}

@keyframes season-twinkle {
  0%,
  100% {
    opacity: 0.2;
  }
  50% {
    opacity: 0.85;
  }
}

@media (prefers-reduced-motion: reduce) {
  .season-p {
    animation: none;
    top: calc(var(--space-6) + 2rem * var(--row, 1));
  }
}
