@font-face {
  font-family: "Pretendard";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./assets/fonts/PretendardVariable.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #000000;
  --bg-grad-top: #000000;
  --surface: rgba(10, 10, 10, 0.84);
  --surface-strong: rgba(10, 10, 10, 0.94);
  --surface-soft: rgba(18, 18, 18, 0.94);
  --text: #f3f4f6;
  --text-soft: #9ca3af;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.45);
  --header: rgba(18, 18, 18, 0.94);
  --accent: #f9fafb;
  --accent-soft: rgba(255, 255, 255, 0.07);
  --today: rgba(96, 165, 250, 0.14);
  --current: rgba(16, 185, 129, 0.16);
  --current-border: rgba(52, 211, 153, 0.45);
  --current-bar: rgba(255, 69, 58, 0.95);
  --next: rgba(250, 204, 21, 0.17);
  --next-border: rgba(250, 204, 21, 0.5);
  --next-bar: rgba(250, 204, 21, 0.96);
  --period-progress: 0%;
  --toggle-bg: rgba(255, 255, 255, 0.08);
  --cursor-x: 50vw;
  --cursor-y: 50vh;
  --rolling-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --rolling-digit-ease: cubic-bezier(0.2, 0.75, 0.25, 1);
  --focus-glow: rgba(255, 255, 255, 0.58);
  --focus-glow-soft: rgba(255, 255, 255, 0.18);
}

body.light-mode {
  color-scheme: light;
  --bg: #f5f5f7;
  --bg-grad-top: #ffffff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --surface-soft: rgba(247, 247, 250, 0.95);
  --text: #111827;
  --text-soft: #6b7280;
  --border: rgba(17, 24, 39, 0.08);
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --header: rgba(250, 250, 252, 0.92);
  --accent: #111827;
  --accent-soft: rgba(17, 24, 39, 0.05);
  --today: rgba(59, 130, 246, 0.08);
  --current: rgba(16, 185, 129, 0.12);
  --current-border: rgba(16, 185, 129, 0.34);
  --current-bar: rgba(255, 59, 48, 0.9);
  --next: rgba(250, 204, 21, 0.2);
  --next-border: rgba(234, 179, 8, 0.42);
  --next-bar: rgba(234, 179, 8, 0.96);
  --toggle-bg: rgba(17, 24, 39, 0.06);
  --focus-glow: rgba(17, 24, 39, 0.72);
  --focus-glow-soft: rgba(17, 24, 39, 0.16);
}

* {
  box-sizing: border-box;
}

body.theme-switching,
body.theme-switching::before,
body.theme-switching::after,
body.theme-switching *,
body.theme-switching *::before,
body.theme-switching *::after {
  transition: none !important;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 480ms;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

:where(h1, h2, h3, h4, h5, h6, strong, b, th, legend) {
  font-weight: 600;
  font-variation-settings: "wght" 600;
}

.iphone-safe-zone {
  display: none;
}

body {
  margin: 0;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-weight: 500;
  background: linear-gradient(180deg, var(--bg-grad-top) 0%, var(--bg) 100%);
  background-attachment: fixed;
  color: var(--text);
  padding: 32px 16px;
  transition: background 0.28s ease, color 0.28s ease;
}

.tile-reset-blackout {
  position: fixed;
  inset: 0;
  z-index: 30000;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

.tile-reset-blackout.is-blanking,
html.tile-reset-returning .tile-reset-blackout {
  pointer-events: auto;
}

html.tile-reset-returning .tile-reset-blackout {
  animation: tileResetReveal 1050ms cubic-bezier(.22, 1, .36, 1) 1050ms both;
}

@keyframes tileResetReveal {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html.tile-reset-returning .tile-reset-blackout {
    animation: tileResetReveal 150ms ease-out both;
  }
}

.startup-spotlight {
  --spotlight-rgb: 255, 255, 255;
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    circle at top left,
    rgba(var(--spotlight-rgb), 0.88) 0%,
    transparent 34%
  );
  transform-origin: 0 0;
  animation:
    startupSpotlightDescend 2.4s cubic-bezier(0.22, 0.61, 0.36, 1) 250ms both,
    startupSpotlightIlluminate 2.4s cubic-bezier(0.4, 0, 0.2, 1) 250ms both;
  will-change: transform, opacity;
}

.startup-spotlight.is-settled {
  animation: none;
  opacity: 1;
  transform: translate3d(0, 0, 0);
  will-change: auto;
}

html.tile-tour-pending .startup-spotlight {
  animation: none;
  opacity: 0;
  transform: translate3d(0, -20vh, 0);
}

html.tile-tour-pending .welcome-title-char-inner {
  animation: none;
  opacity: 0;
  transform: translate3d(0, 0, 0);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle at var(--cursor-x) var(--cursor-y), rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.08) 9rem, transparent 20rem);
  opacity: 1;
  transition: opacity 0.5s ease;
}

body.welcome-active::before {
  opacity: 0;
}

body::after {
  content: "";
  position: fixed;
  top: -10px;
  left: 0;
  right: 0;
  height: max(184px, calc(env(safe-area-inset-top, 0px) + 168px));
  z-index: 880;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(
      180deg,
      rgba(0, 0, 0, 0.72) 0%,
      rgba(0, 0, 0, 0.54) 34%,
      rgba(0, 0, 0, 0.22) 76%,
      rgba(0, 0, 0, 0) 100%
    );
  backdrop-filter: blur(28px) saturate(1.18);
  -webkit-backdrop-filter: blur(28px) saturate(1.18);
  mask-image:
    linear-gradient(
      180deg,
      #000 0%,
      rgba(0, 0, 0, 0.94) 42%,
      rgba(0, 0, 0, 0.5) 82%,
      rgba(0, 0, 0, 0.12) 94%,
      transparent 100%
    );
  -webkit-mask-image:
    linear-gradient(
      180deg,
      #000 0%,
      rgba(0, 0, 0, 0.94) 42%,
      rgba(0, 0, 0, 0.5) 82%,
      rgba(0, 0, 0, 0.12) 94%,
      transparent 100%
    );
  transform: translate3d(0, -8px, 0);
  transition:
    opacity 0.82s cubic-bezier(0.19, 1, 0.22, 1),
    transform 0.88s cubic-bezier(0.19, 1, 0.22, 1);
}

body.floating-topbar-visible::after {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

body.light-mode {
  background: linear-gradient(180deg, var(--bg-grad-top) 0%, var(--bg) 100%);
}

body.light-mode::before {
  background: radial-gradient(
    circle at var(--cursor-x) var(--cursor-y),
    rgba(0, 0, 0, 0.18) 0%,
    rgba(0, 0, 0, 0.08) 9rem,
    transparent 20rem
  );
}

body.light-mode::after {
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.8) 0%,
      rgba(255, 255, 255, 0.6) 34%,
      rgba(255, 255, 255, 0.26) 76%,
      rgba(255, 255, 255, 0) 100%
    );
}

body.has-iphone-safe-zone {
  padding-top: 32px;
}

.floating-topbar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 900;
  isolation: isolate;
  width: min(1184px, calc(100vw - 96px));
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-50%, -28px, 0) scale(0.965);
  filter: blur(10px);
  transition:
    opacity 0.72s cubic-bezier(0.19, 1, 0.22, 1),
    transform 0.86s cubic-bezier(0.19, 1, 0.22, 1),
    filter 0.72s cubic-bezier(0.19, 1, 0.22, 1);
  will-change: opacity, transform, filter;
}

.floating-topbar.is-visible {
  pointer-events: auto;
  opacity: 1;
  transform: translate3d(-50%, 0, 0) scale(1);
  filter: blur(0);
}

.container {
  --container-radius: 28px;
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--container-radius);
  box-shadow: var(--shadow);
  padding: 28px;
  overflow: hidden;
  transition: background 0.28s ease, border-color 0.28s ease, box-shadow 0.28s ease;
  width: 100%;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.hero-copy {
  min-width: 220px;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(1.9rem, 2.8vw, 2.4rem);
  letter-spacing: -0.03em;
  color: var(--accent);
  text-align: left;
}

.welcome-title {
  display: inline-flex;
  align-items: baseline;
  overflow: hidden;
  line-height: 1.08;
}

.welcome-title-char {
  display: inline-flex;
  height: 1.08em;
  overflow: hidden;
  font: inherit;
  line-height: 1.08;
}

.welcome-title-char-inner {
  display: flex;
  flex-direction: column;
  height: 2.16em;
  transform: translate3d(0, 0, 0);
  will-change: transform, opacity;
}

.welcome-title-char-inner > span {
  display: flex;
  align-items: center;
  height: 1.08em;
  flex: 0 0 1.08em;
  font: inherit;
  line-height: 1.08;
}

.welcome-title.is-welcome-rolling .welcome-title-char-inner {
  animation: welcomeTitleRoll 0.82s var(--rolling-ease-out) both;
}

.welcome-title.is-welcome-rolling .welcome-title-char:nth-child(1) .welcome-title-char-inner {
  animation-delay: 0.52s;
}

.welcome-title.is-welcome-rolling .welcome-title-char:nth-child(2) .welcome-title-char-inner {
  animation-delay: 0.66s;
}

.welcome-title.is-welcome-rolling .welcome-title-char:nth-child(3) .welcome-title-char-inner {
  animation-delay: 0.8s;
}

.welcome-title.is-welcome-rolling .welcome-title-char:nth-child(4) .welcome-title-char-inner {
  animation-delay: 0.94s;
}

.subtitle {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  text-align: left;
}

.school-meta-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 10px;
}

.neis-connection {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
  font-size: 0.7rem;
  line-height: 1;
}

.neis-connection::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  opacity: 0.62;
}

.neis-connection span {
  font-weight: 500;
  letter-spacing: 0.02em;
}

.neis-connection strong {
  color: var(--text);
  font-weight: 500;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
  padding-bottom: 17px;
}

.tool-menu {
  position: relative;
}

.tile-version-label {
  position: absolute;
  bottom: 0;
  right: 1px;
  color: var(--text-soft);
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.015em;
  white-space: nowrap;
  pointer-events: none;
}

.controls:has(.tool-menu.is-open) .tile-version-label {
  visibility: hidden;
}

.timetable-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 4px 0 14px;
}
.timetable-actions-primary, .timetable-actions-secondary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.timetable-actions button { min-height: 44px; }
.timetable-actions-hint { color: var(--text-soft); font-size: .875rem; }
.timetable-actions button:active { transform: scale(.97); }
.timetable-actions button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
@media (max-width: 600px) {
  .timetable-actions { gap: 8px; }
  .timetable-actions-primary, .timetable-actions-secondary { width: 100%; }
  .timetable-actions-secondary button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .timetable-actions button { transition: opacity .15s ease; }
  .timetable-actions button:active { transform: none; opacity: .7; }
}

.tool-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 6px;
  min-width: 180px;
  max-height: min(72vh, 640px);
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-strong);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  overflow-y: auto;
  overscroll-behavior: contain;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(.985);
  transform-origin: top right;
  transition: opacity 180ms ease, transform 240ms cubic-bezier(.22,1,.36,1), visibility 0s linear 240ms;
}

.tool-menu.is-open .tool-menu-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition: opacity 180ms ease, transform 240ms cubic-bezier(.22,1,.36,1), visibility 0s;
}

.tool-menu-panel button {
  width: 100%;
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.tool-menu-panel button:hover {
  background: var(--toggle-bg);
  border-color: var(--border);
}

.tool-menu-panel button:active { transform: scale(.98); }

.setup-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.18);
}

.setup-modal.hidden {
  display: none;
}

.setup-modal.is-closing { pointer-events: none; }

.setup-card {
  width: min(92vw, 500px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.settings-card {
  width: min(92vw, 520px);
}

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

.setup-header h2 {
  margin: 0;
  font-size: 1.18rem;
  color: var(--text);
}

.setup-subtitle {
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 0.86rem;
  font-weight: 520;
  line-height: 1.45;
}

#closeSchoolSettings,
#closeAppSettings {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

#schoolInput,
#tileResetConfirmation,
#gradeInput,
#classInput,
#allergyInput,
#subjectEditName,
#subjectEditRoom,
#subjectEditTeacher,
#subjectEditMemo {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  outline: none;
}

#schoolInput:focus,
#gradeInput:focus,
#classInput:focus,
#allergyInput:focus,
#subjectEditName:focus,
#subjectEditRoom:focus,
#subjectEditTeacher:focus,
#subjectEditMemo:focus {
  border-color: var(--focus-glow);
  box-shadow: inset 0 0 0 1px var(--focus-glow-soft);
}

#schoolResults {
  display: grid;
  gap: 6px;
  flex: none;
}

#schoolResults > div {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

#schoolResults > .school-result-empty {
  color: var(--text-soft);
  cursor: default;
}

.selected-school-info {
  display: none;
  grid-template-columns: 0.82fr 1.48fr 1.04fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.selected-school-info.is-visible {
  display: grid;
}

.selected-school-info div {
  min-width: 0;
  text-align: left;
}

.selected-school-info div:nth-child(2) {
  padding-left: 10px;
}

.selected-school-info span {
  display: block;
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 560;
  line-height: 1.3;
}

.selected-school-info strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  word-break: keep-all;
}

.selected-school-info div:nth-child(2) strong {
  white-space: nowrap;
  font-size: 0.8rem;
}

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

.setup-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

#subjectEditMemo {
  min-height: 104px;
  resize: vertical;
  line-height: 1.55;
}

#allergyInput {
  min-height: 112px;
  resize: vertical;
  line-height: 1.55;
}

.settings-help {
  margin: -2px 0 0;
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.45;
}

.theme-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--toggle-bg);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.14);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease, filter 0.16s ease;
}

.theme-toggle:hover {
  transform: translateY(-2px) scale(1.04);
  background: var(--accent-soft);
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.26);
}

.theme-toggle:active {
  transform: translateY(2px) scale(0.96);
  box-shadow: 0 2px 6px rgba(17, 24, 39, 0.28);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 3px;
  box-shadow:
    0 0 0 5px var(--focus-glow-soft),
    0 0 30px var(--focus-glow-soft);
}

.theme-toggle.theme-target-dark {
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}

.theme-toggle.theme-target-dark {
  box-shadow: 0 4px 14px rgba(17, 17, 17, 0.35);
}

.theme-toggle.theme-target-dark:hover {
  box-shadow: 0 12px 26px rgba(17, 17, 17, 0.48);
}

.theme-toggle.theme-target-light {
  background: #ffffff;
  color: #111111;
  border-color: #d1d5db;
}

.theme-toggle.theme-target-light {
  box-shadow: 0 4px 14px rgba(255, 255, 255, 0.12);
}

body.dark-mode .theme-toggle.theme-target-light {
  box-shadow: 0 4px 14px rgba(255, 255, 255, 0.35);
}

body.dark-mode .theme-toggle.theme-target-light:hover {
  box-shadow: 0 12px 26px rgba(255, 255, 255, 0.48);
}

.theme-toggle.theme-target-dark:hover,
.theme-toggle.theme-target-light:hover {
  transform: translateY(-2px) scale(1.04);
  filter: brightness(0.92) saturate(1.18);
}

@keyframes buttonPop {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-2px) scale(1.06); }
  100% { transform: translateY(0) scale(1); }
}

.theme-toggle.popped,
.today-toggle.popped {
  animation: buttonPop 220ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.today-toggle.active {
  background: var(--accent);
  color: var(--bg-grad-top);
  border-color: transparent;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.32), 0 12px 24px rgba(17, 24, 39, 0.28);
}

.today-toggle.active:hover {
  filter: brightness(1.08) saturate(1.12);
}

.today-toggle:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.today-only-hidden {
  color: transparent !important;
}

.today-only-hidden > * {
  opacity: 0 !important;
}

.top-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.status-card,
.summary-card {
  grid-template-columns: 1fr;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
  transition: background 0.28s ease, border-color 0.28s ease;
}

.status-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

#mainContent .status-card {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px 16px;
}

#mainContent .status-card-classic {
  grid-template-columns:
    minmax(0, 0.92fr)
    minmax(0, 1.34fr)
    minmax(0, 1.18fr)
    minmax(0, 1.16fr)
    minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

#mainContent .status-item-primary {
  grid-column: auto;
  padding: 0;
}

#mainContent .status-item-secondary {
  grid-column: auto;
  padding: 0;
}

#mainContent .status-item-time { order: 1; }
#mainContent .status-item-period { order: 2; }
#mainContent .status-item-room { order: 3; }
#mainContent .status-item-remaining { order: 4; }
#mainContent .status-item-day { order: 5; }
#mainContent .status-item-neis { order: 6; }

html[data-status-layout="focused"] #mainContent .status-card-classic {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0 18px;
}

html[data-status-layout="focused"] #mainContent .status-item-primary {
  grid-column: span 2;
  padding: 3px 0 17px;
}

html[data-status-layout="focused"] #mainContent .status-item-secondary {
  grid-column: span 3;
  padding: 13px 0 1px;
  border-top: 1px solid var(--border);
}

html[data-status-layout="focused"] #mainContent .status-item-period { order: 1; }
html[data-status-layout="focused"] #mainContent .status-item-room { order: 2; }
html[data-status-layout="focused"] #mainContent .status-item-remaining { order: 3; }
html[data-status-layout="focused"] #mainContent .status-item-time { order: 4; }
html[data-status-layout="focused"] #mainContent .status-item-day { order: 5; }

#mainContent .status-item-primary .status-label {
  color: var(--text-soft);
}

#mainContent .status-item-primary .status-value {
  font-size: 1rem;
  line-height: 1.4;
}

#mainContent .status-item-secondary .status-label {
  font-size: 0.8rem;
}

#mainContent .status-item-secondary .status-value {
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.summary-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.status-label,
.summary-label {
  font-size: 0.8rem;
  color: var(--text-soft);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.status-value,
.summary-value {
  font-size: 1rem;
  color: var(--text);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.02em;
  word-break: keep-all;
}

.table-shell {
  position: relative;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 14px;
  overflow-x: auto;
  overflow-y: visible;
  transition: background 0.28s ease, border-color 0.28s ease;
}

.setup-school-panel, .setup-choice-panel { display: grid; gap: 16px; flex: none; min-width: 0; }
.setup-school-panel[hidden], .setup-choice-panel[hidden], .setup-back[hidden] { display: none; }
.setup-choice-panel { gap: 10px; padding-top: 6px; }
.setup-choice-panel .form-message:empty { display: none; }
.setup-choice {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.setup-choice strong, .setup-choice-login strong { display: block; font-size: .96rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; }
.setup-choice small, .setup-choice-login small { display: block; margin-top: 5px; font-size: .76rem; font-weight: 450; line-height: 1.5; }
.setup-choice small { color: var(--text-soft); }
.setup-choice-symbol { display: grid; place-items: center; width: 32px; height: 32px; color: var(--text); }
.setup-choice-symbol svg { width: 25px; height: 25px; }
.setup-choice-chevron { width: 16px; height: 16px; color: var(--text-soft); }
.account-lightframe-toggle.setup-choice-login { min-height: 76px; padding: 14px 16px; text-align: left; justify-content: flex-start; gap: 12px; }
.setup-choice-login .account-lightframe-mark { flex-basis: 32px; width: 32px; margin: 0; font-size: 26px; }
.setup-back { display: inline-flex; align-items: center; justify-self: start; gap: 7px; min-height: 40px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); color: var(--text); font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer; transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease; }
.setup-back svg { width: 15px; height: 15px; flex: none; }
.setup-choice:focus-visible, .setup-back:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
@media (hover: hover) {
  .setup-choice:hover { background: var(--toggle-bg); border-color: var(--text-soft); }
  .setup-back:hover { background: var(--toggle-bg); border-color: var(--text-soft); }
}
.setup-choice:active, .setup-back:active { opacity: .75; transform: scale(.985); transition: none; }
.setup-choice:disabled { opacity: .55; cursor: wait; }
@media (prefers-reduced-motion: reduce) {
  .setup-choice, .setup-back { transition: opacity 150ms ease; }
  .setup-choice:active, .setup-back:active { transform: none; }
}

.after-school-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  font-size: .875rem;
  color: var(--text-soft);
}
.after-school-dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  box-sizing: border-box;
  overflow: auto;
  padding: 24px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 24px 90px #0006;
}
.after-school-dialog::backdrop { background: #0008; backdrop-filter: blur(8px); }
.after-school-heading, .after-school-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.after-school-heading h2 { margin: 0; font-size: 1.6rem; letter-spacing: -.02em; line-height: 1.1; }
.after-school-description { color: var(--text-soft); font-size: .875rem; line-height: 1.6; }
.after-school-list { max-height: 38dvh; overflow: auto; margin-block: 20px; }
.after-school-item { padding-block: 8px; font-size: .9375rem; }
.after-school-item span { min-width: 0; overflow-wrap: anywhere; }
.after-school-item button { flex-shrink: 0; }
.after-school-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.after-school-inputs label { display: grid; gap: 8px; min-width: 0; font-size: .875rem; }
.after-school-inputs input { width: 100%; min-width: 0; box-sizing: border-box; font: inherit; font-size: 1rem; padding: 12px; border-radius: 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border); }
.after-school-inputs button { grid-column: 1 / -1; }
.after-school-dialog button, .after-school-toolbar button { min-height: 44px; }
.after-school-dialog button:active, .after-school-toolbar button:active { transform: scale(.97); }
.after-school-dialog button:focus-visible, .after-school-toolbar button:focus-visible,
tr[data-edit-bound] [role="button"]:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.after-school-dialog button:disabled { opacity: .45; cursor: not-allowed; }
.preset-save-form { display: grid; gap: 10px; font-size: .875rem; }
.preset-save-form input { box-sizing: border-box; min-width: 0; width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; font-size: 1rem; }
.preset-item { display: grid; gap: 10px; padding: 12px 0; }
.preset-item strong { overflow-wrap: anywhere; font-size: 1rem; }
.preset-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-menu-panel button:disabled { opacity: .45; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) {
  .after-school-dialog *, .after-school-toolbar * { transition: opacity .15s ease !important; transform: none !important; }
}

.site-footer {
  margin-top: 18px;
  padding: 14px 4px 2px;
  color: var(--text-soft);
  font-size: 0.88rem;
  line-height: 1.55;
  text-align: center;
}

.site-footer strong {
  color: var(--text);
  font-weight: 600;
}

.custom-panel {
  display: none;
  margin-bottom: 24px;
  padding: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.custom-panel.is-open {
  display: block;
}

.meal-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.meal-card {
  min-height: 136px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
}

.meal-type {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 600;
}

.meal-card p {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.55;
  word-break: keep-all;
  white-space: pre-line;
}

.meal-warning {
  display: none;
  margin-top: 12px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 69, 58, 0.34);
  border-radius: 12px;
  background: rgba(255, 69, 58, 0.12);
  color: #ff8a80;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
}

.meal-warning.is-visible {
  display: block;
}

.mode-hidden {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.18);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.32s ease, visibility 0s linear 0.32s;
}

.overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  transition: opacity 0.32s cubic-bezier(.2,.9,.2,1);
  pointer-events: none;
}

.overlay:not(.hidden) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.32s ease, visibility 0s linear 0s;
}
.overlay:not(.hidden)::before {
  opacity: 1;
}

/* Keep the underlay faint while the subject editor is dismissed. */
.overlay.hidden::before {
  opacity: 0;
}

.subject-modal {
  position: relative;
  z-index: 1;
  width: min(92vw, 560px);
  min-height: 236px;
  padding: 52px 28px 28px;
  border-radius: 22px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text);
  transform: scale(0.96) translateY(6px);
  opacity: 0;
  /* The interruptible Web Animation owns the surface transition. */
  transition: none;
  max-height: 85dvh;
  overflow-y: auto;
}

body.dark-mode .subject-modal {
  background: var(--surface-strong);
  border-color: var(--border);
  box-shadow: var(--shadow);
}

body.light-mode .subject-modal {
  background: var(--surface-strong);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.overlay:not(.hidden) .subject-modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

#closeModal {
  appearance: none;
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

#closeModal:hover {
  transform: translateY(-2px) scale(1.04);
  background: var(--toggle-bg);
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.14);
}

#closeModal:active {
  transform: translateY(1px) scale(0.96);
}

#modalInfoMode,
#modalInputMode,
#subjectEditMode,
#subjectBulkMode {
  min-height: 154px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
}

.subject-modal h2 {
  font-size: 1.28rem;
  font-weight: 600;
  margin: 0 0 12px;
  padding: 0 42px;
  line-height: 1.5;
  color: #f3f4f6;
  letter-spacing: -0.02em;
}

body.light-mode .subject-modal h2 {
  color: var(--text);
}

.subject-modal p {
  color: var(--text-soft);
  margin: 6px 0 0;
  line-height: 1.5;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

body.light-mode .subject-modal p {
  color: var(--text-soft);
  background: transparent;
}

.field-label {
  margin: 10px 0 6px;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
}

.subject-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.subject-actions button {
  appearance: none;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--toggle-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.subject-actions button:hover {
  transform: translateY(-2px);
  background: var(--accent-soft);
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.14);
}

.subject-bulk-help {
  max-width: 420px;
  margin: -2px auto 14px;
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

.subject-bulk-list {
  display: grid;
  gap: 10px;
  max-height: min(46vh, 440px);
  padding-right: 2px;
  overflow-y: auto;
}

.subject-bulk-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
}

.subject-bulk-day {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--toggle-bg);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.subject-bulk-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.subject-bulk-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.subject-bulk-field:last-child {
  grid-column: 1 / -1;
}

.subject-bulk-field span {
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
}

.subject-bulk-field input,
.subject-bulk-field textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.35;
  outline: none;
  resize: vertical;
  transition: box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.subject-bulk-field input:focus,
.subject-bulk-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

#subjectEditSave {
  background: var(--accent);
  color: var(--bg);
}

#saveSchool,
#saveAppSettings,
#subjectEditSave,
#subjectBulkSave,
#customSave {
  background: var(--accent);
  color: var(--bg);
  border-color: transparent;
}

#saveSchool:hover,
#saveAppSettings:hover,
#subjectEditSave:hover,
#subjectBulkSave:hover,
#customSave:hover {
  transform: translateY(-2px) scale(1.03);
  filter: brightness(1.05) saturate(1.08);
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.26);
}

body.dark-mode #saveSchool:hover,
body.dark-mode #saveAppSettings:hover,
body.dark-mode #subjectEditSave:hover,
body.dark-mode #subjectBulkSave:hover,
body.dark-mode #customSave:hover {
  box-shadow: 0 12px 26px rgba(255, 255, 255, 0.28);
}

#modalInput {
  width: 100%;
  margin-top: 8px;
  padding: 15px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  line-height: 1.5;
  text-align: left;
  outline: none;
  transition: box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

body.dark-mode #modalInput {
  background: var(--surface-soft);
  border-color: var(--border);
}

body.light-mode #modalInput {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border);
}

#modalInput:focus {
  border-color: var(--border);
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}

body.dark-mode #modalInput:focus {
  border-color: var(--border);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}

#modalConfirm {
  margin-top: 18px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.14);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease, filter 0.16s ease;
}

#modalConfirm:hover {
  transform: translateY(-2px);
  background: var(--accent);
  filter: brightness(0.96) saturate(1.08);
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.26);
}

#modalConfirm:active {
  transform: translateY(2px) scale(0.96);
  box-shadow: 0 2px 6px rgba(17, 24, 39, 0.28);
}

#modalConfirm:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 3px;
}

body.dark-mode #modalConfirm {
  background: #ffffff;
  border-color: #d1d5db;
  color: #111111;
  box-shadow: 0 4px 14px rgba(255, 255, 255, 0.18);
}

body.dark-mode #modalConfirm:hover {
  background: #ffffff;
  box-shadow: 0 12px 26px rgba(255, 255, 255, 0.28);
}

body.dark-mode #modalConfirm:active {
  box-shadow: 0 2px 6px rgba(255, 255, 255, 0.18);
}

body.dark-mode #modalConfirm:focus-visible {
  box-shadow: 0 6px 18px rgba(255, 255, 255, 0.26);
}

.custom-panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.custom-panel h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.custom-panel p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.5;
}

.meal-refresh-link {
  appearance: none;
  margin-top: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 42%, transparent);
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.16s ease, transform 0.16s ease;
}

.meal-refresh-link:hover {
  color: var(--text);
}

.meal-refresh-link:active {
  transform: scale(0.98);
}

.meal-refresh-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

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

.custom-close {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--toggle-bg);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

#customTimetableInput,
#memoInput,
#subjectMemo {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  outline: none;
}

#customTimetableInput:focus,
#memoInput:focus,
#subjectMemo:focus {
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}

.custom-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.custom-help {
  margin-top: 12px !important;
  font-size: 0.82rem !important;
}

table {
  position: relative;
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  color: var(--text);
}

col.time-col {
  width: 18%;
}

col.day-col {
  width: 16.4%;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--header);
  color: var(--accent);
  font-weight: 600;
  padding: 16px 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

thead th:first-child {
  border-left: 1px solid var(--border);
  border-top-left-radius: 16px;
}

thead th:last-child {
  border-top-right-radius: 16px;
}

tbody th,
tbody td {
  position: relative;
  background: transparent;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 14px 12px;
  text-align: center;
  vertical-align: middle;
  transition: background-color 0.22s ease, border-color 0.22s ease, transform 0.22s ease;
}

tbody tr > *:first-child {
  border-left: 1px solid var(--border);
}

tbody tr:last-child > *:first-child {
  border-bottom-left-radius: 16px;
}

tbody tr:last-child > *:last-child {
  border-bottom-right-radius: 16px;
}

tbody th {
  background: var(--header);
  color: var(--accent);
  font-weight: 600;
  white-space: normal;
  word-break: keep-all;
  font-size: 0.9rem;
  line-height: 1.35;
}

td {
  font-size: 0.96rem;
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: break-word;
  color: var(--text);
}

tbody td:hover,
tbody th:hover {
  position: relative;
  z-index: 4;
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.22),
    inset 0 0 28px rgba(255, 255, 255, 0.14),
    0 0 24px rgba(255, 255, 255, 0.22);
}

.time {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--text-soft);
  font-weight: 500;
  line-height: 1.4;
}

.subject {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 56px;
}

.subject-name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32em;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.memo-indicator {
  position: static;
  display: inline-block;
  flex: 0 0 auto;
  margin-left: 0;
  color: currentColor;
  font-size: 0.72em;
  line-height: 1;
  text-shadow:
    0 0 6px rgba(255, 255, 255, 0.58),
    0 1px 2px rgba(0, 0, 0, 0.35);
}

.room-info,
.teacher-info {
  display: block;
  width: 100%;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.7rem;
  font-weight: 450;
  line-height: 1.35;
  text-align: center;
}

.subject-name + .room-info {
  margin-top: 5px;
}

.teacher-info {
  margin-top: 1px;
  opacity: 0.8;
}

.meal,
.homeroom {
  background: transparent;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.daily-homeroom {
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.daily-homeroom strong {
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.daily-homeroom span {
  color: var(--text-soft);
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
}

.daily-homeroom-cell {
  cursor: pointer;
  background: color-mix(in srgb, var(--surface-soft) 42%, transparent);
}

tbody tr.today-row > th,
tbody tr.today-row > td.today-cell {
  background: var(--today);
}

tbody tr.current-row > th,
tbody tr.current-row > td {
  background: var(--current);
  box-shadow: inset 0 0 0 1px var(--current-border);
}

tbody tr.current-row > td.current-glow-cell {
  position: relative;
  z-index: 4;
  background: rgba(16, 185, 129, 0.19);
  box-shadow:
    inset 0 0 0 1px rgba(52, 211, 153, 0.58),
    inset 0 0 22px rgba(16, 185, 129, 0.22),
    0 0 18px rgba(16, 185, 129, 0.28);
}

tbody tr.current-row > td:hover,
tbody tr.current-row > th:hover {
  position: relative;
  z-index: 4;
  background: rgba(16, 185, 129, 0.24);
  box-shadow:
    inset 0 0 0 1px rgba(52, 211, 153, 0.72),
    inset 0 0 32px rgba(16, 185, 129, 0.34),
    0 0 28px rgba(16, 185, 129, 0.48);
}

tbody tr.break-target-row > th,
tbody tr.break-target-row > td {
  background: var(--next);
  box-shadow: inset 0 0 0 1px var(--next-border);
}

tbody tr.break-target-row > td.next-glow-cell {
  position: relative;
  z-index: 4;
  background: rgba(250, 204, 21, 0.26);
  box-shadow:
    inset 0 0 0 1px rgba(250, 204, 21, 0.72),
    inset 0 0 24px rgba(250, 204, 21, 0.28),
    0 0 20px rgba(250, 204, 21, 0.36);
}

tbody tr.break-target-row > td:hover,
tbody tr.break-target-row > th:hover {
  position: relative;
  z-index: 4;
  background: rgba(250, 204, 21, 0.3);
  box-shadow:
    inset 0 0 0 1px rgba(250, 204, 21, 0.82),
    inset 0 0 32px rgba(250, 204, 21, 0.34),
    0 0 28px rgba(250, 204, 21, 0.46);
}

tbody tr.current-row > th::after,
tbody tr.current-row > td::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: calc((100% - 3px) * var(--period-progress) / 100);
  height: 3px;
  background: var(--current-bar);
  z-index: 3;
  pointer-events: none;
}

tbody tr.current-row > th::after {
  left: 12px;
  border-top-left-radius: 999px;
  border-bottom-left-radius: 999px;
}

tbody tr.current-row > td:last-of-type::after {
  right: 12px;
  border-top-right-radius: 999px;
  border-bottom-right-radius: 999px;
}

tbody tr.current-row > th {
  overflow: visible;
}

tbody tr.current-row > th .time-marker {
  position: absolute;
  left: 8px;
  top: calc((100% - 20px) * var(--period-progress) / 100);
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--current-bar);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  z-index: 5;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
}

tbody tr.break-target-row > td::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: 0;
  height: 3px;
  background: var(--next-bar);
  z-index: 3;
  pointer-events: none;
}

tbody tr.break-target-row > td:first-of-type::after {
  left: 12px;
  border-top-left-radius: 999px;
  border-bottom-left-radius: 999px;
}

tbody tr.break-target-row > td:last-of-type::after {
  right: 12px;
  border-top-right-radius: 999px;
  border-bottom-right-radius: 999px;
}

tbody tr.break-target-row > th {
  overflow: visible;
}

tbody tr.break-target-row > th .time-marker {
  position: absolute;
  left: 8px;
  top: 0;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--next-bar);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  z-index: 5;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
}

thead th.today-column-header {
  background: var(--today);
}

thead th.today-column-header:hover {
  background: rgba(59, 130, 246, 0.18);
  box-shadow:
    inset 0 0 0 1px rgba(96, 165, 250, 0.68),
    inset 0 0 26px rgba(59, 130, 246, 0.24),
    0 0 24px rgba(59, 130, 246, 0.36);
}

thead th.current-day-column-header {
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.3);
}

.empty-cell {
  cursor: pointer;
}

.neis-empty-cell {
  color: var(--text-soft);
}

.neis-empty-cell .subject-name {
  font-size: 0.86rem;
  font-weight: 600;
  opacity: 0.72;
}

.empty-cell:hover {
  background: rgba(255, 255, 255, 0.12);
}

.floating-time-line {
  position: absolute;
  height: 3px;
  background: var(--current-bar);
  border-radius: 999px;
  z-index: 1;
  pointer-events: none;
}

tbody tr.current-row > td > * {
  position: relative;
  z-index: 2;
}

.floating-time-label {
  position: absolute;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  contain: layout paint;
  box-sizing: border-box;
  width: 84px;
  min-width: 84px;
  max-width: 84px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--current-bar);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  z-index: 7;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
  will-change: transform;
}

.floating-time-line.next-time-line,
.floating-time-label.next-time-line {
  background: var(--current-bar);
}

tbody tr.current-row > th::after,
tbody tr.current-row > td::after,
tbody tr.break-target-row > td::after {
  content: none !important;
}

tbody tr.current-row > th .time-marker,
tbody tr.break-target-row > th .time-marker {
  display: none !important;
}

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

  .status-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #mainContent .status-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #mainContent .status-item-primary,
  #mainContent .status-item-secondary {
    grid-column: span 1;
  }
}

body.mobile-today-mode table {
  width: 100%;
  min-width: 0;
}

body.mobile-today-mode col.time-col {
  width: 44%;
}

body.mobile-today-mode col.day-col {
  width: 56%;
}

@media (max-width: 768px) {

  body {
    padding: 12px 8px;
  }

  .setup-card,
  .subject-modal {
    width: min(90vw, 420px);
    max-height: min(88vh, 720px);
    border-radius: 22px;
  }

  .setup-card {
    padding: 20px;
  }

  .selected-school-info {
    grid-template-columns: 1fr;
  }

  .selected-school-info div:nth-child(2) strong {
    white-space: normal;
  }

  .subject-modal {
    min-height: 220px;
    padding: 44px 24px 24px;
  }

  .floating-topbar {
    width: calc(100vw - 20px);
  }

  .meal-list,
  .subject-actions {
    grid-template-columns: 1fr;
  }

  .subject-bulk-row,
  .subject-bulk-fields {
    grid-template-columns: 1fr;
  }

  .subject-bulk-day {
    min-height: 38px;
  }

  .iphone-safe-zone {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(env(safe-area-inset-top, 0px) + 5px);
    background: #ffffff;
    z-index: 9999;
    pointer-events: none;
  }

  body.has-iphone-safe-zone {
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
  }

  .container {
    --container-radius: 20px;
    padding: 14px;
    border-radius: 20px;
  }

  .hero {
    gap: 14px;
    margin-bottom: 18px;
  }

  h1 {
    font-size: 1.55rem;
  }

  .subtitle {
    font-size: 0.9rem;
  }

  .status-card,
  .summary-card {
    padding: 12px;
    border-radius: 16px;
  }

  .status-card,
  .summary-card {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .status-value,
  .summary-value {
    font-size: 0.92rem;
  }

  #mainContent .status-item-primary .status-value,
  #mainContent .status-item-secondary .status-value {
    font-size: 0.92rem;
  }

  .table-shell {
    padding: 8px;
    border-radius: 18px;
  }

  table {
    min-width: 860px;
  }

  body.mobile-today-mode table {
    width: 100%;
    min-width: 0;
  }

  body.mobile-today-mode col.time-col {
    width: 44%;
  }

  body.mobile-today-mode col.day-col {
    width: 56%;
  }

  body.mobile-today-mode .today-only-hidden {
    display: none !important;
  }

  thead th,
  tbody th,
  td {
    padding: 10px 8px;
  }

  thead th,
  td {
    font-size: 0.82rem;
  }

  .subject-name {
    font-size: 12px;
  }

  tbody th {
    font-size: 0.78rem;
  }

  .time {
    font-size: 0.68rem;
  }

  .room-info,
  .teacher-info {
    font-size: 0.67rem;
  }

  tbody tr.current-row > th::after,
  tbody tr.current-row > td::after {
    top: calc((100% - 3px) * var(--period-progress) / 100);
    height: 3px;
  }

  tbody tr.current-row > th .time-marker {
    left: 6px;
    min-width: 36px;
    padding: 2px 6px;
    font-size: 0.66rem;
  }

  tbody tr.break-target-row > th .time-marker {
    left: 6px;
    min-width: 36px;
    padding: 2px 6px;
    font-size: 0.66rem;
  }

  .controls {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    gap: 8px;
  }

  .theme-toggle {
    width: 100%;
    white-space: nowrap;
    flex: 1 1 auto;
    padding: 10px 12px;
  }

  .tool-menu {
    width: 100%;
  }

  .tool-menu-panel {
    left: 0;
    right: auto;
    width: min(100%, 280px);
  }

  .floating-time-label {
    min-width: 40px;
    padding: 2px 7px;
    font-size: 0.66rem;
  }

  .custom-panel {
    padding: 13px;
    border-radius: 16px;
  }

  .custom-panel-header {
    flex-direction: column;
  }

  #customTimetableInput {
    min-height: 240px;
    font-size: 0.76rem;
  }

  #subjectEditName,
  #subjectEditRoom,
  #subjectEditTeacher,
  #subjectEditMemo,
  #schoolInput,
  #gradeInput,
  #classInput,
  #allergyInput {
    font-size: 16px;
  }
}

@media (max-width: 520px) {
  .status-card,
  .summary-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {

  body {
    padding: 6px;
  }

  .setup-card,
  .subject-modal {
    width: min(90vw, 340px);
    min-height: 214px;
  }

  .setup-card {
    padding: 16px;
  }

  .subject-modal {
    padding: 42px 18px 22px;
  }


  #closeModal {
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
  }

  #modalInfoMode,
  #modalInputMode,
  #subjectEditMode,
  #subjectBulkMode {
    min-height: 160px;
  }

  .subject-modal h2 {
    font-size: 21px;
    padding: 0 36px;
  }

  .container {
    --container-radius: 16px;
    padding: 10px;
    border-radius: 16px;
  }

  .theme-toggle {
    width: 100%;
    font-size: 13px;
  }

  .controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .tool-menu-panel {
    left: 0;
    right: auto;
    width: 100%;
  }

  .table-shell {
    padding: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 680px;
  }

  h1 {
    font-size: 30px;
  }

  .status-value {
    font-size: 14px;
  }

  #mainContent .status-item-primary .status-value,
  #mainContent .status-item-secondary .status-value {
    font-size: 14px;
  }

  .subject-name {
    font-size: 11px;
  }

}
/* ===== Rolling Clock ===== */

#currentTime,
#currentPeriod,
#remainingTime,
#dayRemainingTime,
#currentRoom,
#neisStatus,
#topbarTime,
#topbarPeriod,
#topbarRemaining,
#topbarDayRemaining,
#topbarRoom,
#topbarNeis {
  display: inline-flex;
  align-items: center;
  gap: 0;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: inherit;
  font-weight: 600;
  font-variation-settings: "wght" 600;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Keep the compact floating status bar inside its own grid cells. */
.floating-topbar .status-item {
  min-width: 0;
}

#topbarTime,
#topbarPeriod,
#topbarRemaining,
#topbarDayRemaining,
#topbarRoom,
#topbarNeis {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timetable-edit-action {
  background: var(--text);
  color: var(--bg);
}

.timetable-edit-action:hover {
  background: color-mix(in srgb, var(--text) 88%, var(--bg));
}

#mainContent .status-card .status-value {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.time-char {
  position: relative;
  font: inherit;
  height: 1em;
  line-height: 1;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.58em;
  min-width: 0.58em;
  text-align: center;
  vertical-align: middle;
}

.tile-start-digit-track {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  flex: none;
  font: inherit;
  line-height: 1;
}

.clock-seconds-window {
  position: relative;
  display: inline-block;
  height: 1em;
  overflow: hidden;
  font: inherit;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  vertical-align: middle;
}

.clock-seconds-sizer {
  display: block;
  line-height: 1;
  visibility: hidden;
}

.clock-second-value {
  position: absolute;
  inset: 0;
  display: block;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  will-change: transform, opacity;
}

.time-char.rolling {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 18%, #000 82%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 18%, #000 82%, transparent 100%);
}

.time-separator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  height: 1em;
  line-height: 1;
  min-width: 0.32em;
  text-align: center;
  vertical-align: middle;
}

.time-space {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  height: 1em;
  line-height: 1;
  width: 0.25em;
  vertical-align: middle;
}

.time-label-char {
  display: inline-flex;
  align-items: center;
  font: inherit;
  height: 1em;
  line-height: 1;
  vertical-align: middle;
}

.time-char-inner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  height: 2em;
  width: 100%;
  transform: translate3d(0, 0, 0);
  will-change: transform;
  backface-visibility: hidden;
}

.time-char.animate .time-char-inner {
  transition: transform 520ms var(--rolling-digit-ease);
}

#neisStatus .time-char.animate .time-char-inner,
#topbarNeis .time-char.animate .time-char-inner {
  transition-duration: 900ms;
}

.text-roll-swap {
  animation: textRollSwap 0.42s var(--rolling-ease-out) both;
}

.time-static,
.time-old,
.time-new {
  height: 1em;
  font: inherit;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.floating-time-label .time-char,
.time-marker .time-char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1em;
  line-height: 1;
  vertical-align: middle;
}

.floating-time-label .time-separator,
.floating-time-label .time-space,
.floating-time-label .time-label-char,
.time-marker .time-separator,
.time-marker .time-space,
.time-marker .time-label-char {
  display: inline-flex;
  align-items: center;
  height: 1em;
  line-height: 1;
  vertical-align: middle;
}

.floating-time-label .time-char-inner,
.time-marker .time-char-inner {
  height: 2em;
}

.floating-time-label .time-static,
.floating-time-label .time-old,
.floating-time-label .time-new,
.time-marker .time-static,
.time-marker .time-old,
.time-marker .time-new {
  height: 1em;
  line-height: 1;
}

@keyframes textRollSwap {
  0% {
    opacity: 0;
    transform: translateY(0.42em);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes startupSpotlightDescend {
  0% {
    transform: translate3d(0, -20vh, 0);
  }

  100% {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes startupSpotlightIlluminate {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@keyframes welcomeTitleRoll {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0);
  }

  18% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translate3d(0, -1.08em, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .startup-spotlight,
  .text-roll-swap,
  .setup-modal:not(.hidden) .setup-card {
    animation: none !important;
  }

  .time-char.animate .time-char-inner {
    transition: none !important;
  }

  .floating-topbar,
  body::after {
    transition-duration: 0.01ms !important;
  }

  .welcome-title.is-welcome-rolling .welcome-title-char-inner {
    animation: none !important;
    opacity: 1;
    transform: translate3d(0, -1.08em, 0);
  }
}

#setup-screen {
  transition: opacity 0.4s ease;
}

#app-screen {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.5s ease;
}

#app-screen.show {
  opacity: 1;
  transform: translateY(0);
}

.current-class {
  background: rgba(20,255,150,0.05);
  border: 1px solid rgba(20,255,150,0.15);
  backdrop-filter: blur(10px);
}

@keyframes pulse {
  0% { opacity: .7; }
  50% { opacity: 1; }
  100% { opacity: .7; }
}

/* ===== Secondary UI system: dialogs, tools and editors ===== */

.setup-modal,
.overlay {
  padding: 20px;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px) saturate(1.08);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
}

body.light-mode .setup-modal,
body.light-mode .overlay {
  background: rgba(17, 24, 39, 0.18);
}

.setup-card,
.subject-modal {
  border: 1px solid var(--border);
  background: var(--surface-strong);
  box-shadow:
    0 28px 72px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.light-mode .setup-card,
body.light-mode .subject-modal {
  box-shadow:
    0 28px 72px rgba(15, 23, 42, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.setup-card {
  width: min(92vw, 548px);
  max-height: min(86dvh, 760px);
  gap: 16px;
  padding: 24px;
  overflow-y: auto;
  border-radius: 22px;
}

.settings-card {
  width: min(92vw, 500px);
}

.settings-section {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.settings-section-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.3;
}

.settings-section-header p {
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.5;
}

.settings-section .settings-help {
  margin-top: -4px;
}

.setup-header {
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 2px;
}

.setup-header > div {
  min-width: 0;
}

.setup-header h2,
.subject-modal h2,
.custom-panel h2 {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
  text-align: left;
}

.setup-subtitle {
  max-width: 470px;
  margin: 7px 0 0;
  color: var(--text-soft);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0;
  word-break: keep-all;
}

.dialog-close,
#closeSchoolSettings,
#closeAppSettings,
#closeModal,
.custom-close {
  position: relative;
  inset: auto;
  flex: 0 0 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--toggle-bg);
  color: var(--text-soft);
  box-shadow: none;
  font: inherit;
  font-size: 1.28rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.dialog-close:hover,
#closeSchoolSettings:hover,
#closeAppSettings:hover,
#closeModal:hover,
.custom-close:hover {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--focus-glow-soft);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.dialog-close:active,
#closeSchoolSettings:active,
#closeAppSettings:active,
#closeModal:active,
.custom-close:active {
  transform: scale(0.94);
}

.setup-field,
.subject-bulk-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  margin: 0;
}

.setup-field > span,
.field-label,
.subject-bulk-field > span {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
  text-align: left;
}

#schoolInput,
#tileResetConfirmation,
#gradeInput,
#classInput,
#allergyInput,
#subjectEditName,
#subjectEditRoom,
#subjectEditTeacher,
#subjectEditMemo,
#modalInput,
#showcaseTitleInput,
#showcaseAuthorInput,
#showcaseDescriptionInput,
#sharedShowcaseLink,
.subject-bulk-field input,
.subject-bulk-field textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
  text-align: left;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

#schoolInput:hover,
#tileResetConfirmation:hover,
#gradeInput:hover,
#classInput:hover,
#allergyInput:hover,
#subjectEditName:hover,
#subjectEditRoom:hover,
#subjectEditTeacher:hover,
#subjectEditMemo:hover,
#modalInput:hover,
#showcaseTitleInput:hover,
#showcaseAuthorInput:hover,
#showcaseDescriptionInput:hover,
#sharedShowcaseLink:hover,
.subject-bulk-field input:hover,
.subject-bulk-field textarea:hover {
  border-color: var(--focus-glow-soft);
}

#schoolInput:focus,
#tileResetConfirmation:focus,
#gradeInput:focus,
#classInput:focus,
#allergyInput:focus,
#subjectEditName:focus,
#subjectEditRoom:focus,
#subjectEditTeacher:focus,
#subjectEditMemo:focus,
#modalInput:focus,
#showcaseTitleInput:focus,
#showcaseAuthorInput:focus,
#showcaseDescriptionInput:focus,
#sharedShowcaseLink:focus,
.subject-bulk-field input:focus,
.subject-bulk-field textarea:focus {
  border-color: var(--focus-glow);
  background: var(--surface-strong);
  box-shadow: 0 0 0 3px var(--focus-glow-soft);
}

#allergyInput,
#subjectEditMemo,
#showcaseDescriptionInput,
.subject-bulk-field textarea {
  resize: vertical;
}

#allergyInput {
  min-height: 110px;
}

#subjectEditMemo {
  min-height: 96px;
}

.setup-row {
  gap: 12px;
}

.setup-actions {
  margin-top: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .tool-menu-panel,
  .tool-menu.is-open .tool-menu-panel { transform: none; transition: opacity 150ms ease, visibility 0s; }
}

.setup-actions .theme-toggle,
.subject-actions button,
#modalConfirm {
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.3;
}

.setup-actions .theme-toggle:hover,
.subject-actions button:hover,
#modalConfirm:hover {
  transform: translateY(-1px);
}

#schoolResults {
  gap: 6px;
  margin-top: -6px;
  padding: 0 2px;
  border-radius: 14px;
}

#schoolResults > div {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-soft);
  font-size: 0.86rem;
  font-weight: 600;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

#schoolResults > div:not(.school-result-empty):hover {
  background: var(--accent-soft);
  border-color: var(--focus-glow-soft);
  transform: translateX(2px);
}

.selected-school-info {
  grid-template-columns: 0.8fr 1.55fr 1.05fr;
  gap: 0;
  padding: 13px 14px;
  border-radius: 14px;
  background: var(--surface-soft);
}

.selected-school-info div {
  padding: 0 12px;
  border-left: 1px solid var(--border);
}

.selected-school-info div:first-child {
  padding-left: 0;
  border-left: 0;
}

.selected-school-info div:last-child {
  padding-right: 0;
}

.selected-school-info div:nth-child(2) {
  padding-left: 12px;
}

.selected-school-info span {
  font-size: 0.7rem;
  font-weight: 600;
}

.selected-school-info strong,
.selected-school-info div:nth-child(2) strong {
  margin-top: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.settings-help {
  margin: -5px 0 0;
  font-size: 0.78rem;
  font-weight: 500;
}

.subject-modal {
  width: min(92vw, 560px);
  min-height: 0;
  max-height: min(86vh, 760px);
  padding: 24px;
  border-radius: 22px;
}

#subjectModal:has(#subjectBulkMode:not(.mode-hidden)) {
  width: min(94vw, 780px);
}

#closeModal {
  position: absolute;
  top: 18px;
  right: 18px;
}

#modalInfoMode,
#modalInputMode,
#subjectEditMode,
#subjectBulkMode {
  min-height: 0;
  padding-top: 2px;
  text-align: left;
}

#modalInfoMode {
  align-items: center;
  justify-content: center;
  min-height: 170px;
  padding: 34px 42px 12px;
  text-align: center;
}

#modalInfoMode h2 {
  width: 100%;
  margin-bottom: 16px;
  padding: 0;
  text-align: center;
}

#modalInfoMode p {
  width: 100%;
  margin: 0;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 550;
  text-align: center;
}

#modalInputMode,
#subjectEditMode,
#subjectBulkMode {
  padding-top: 2px;
}

#modalInputMode h2,
#subjectEditMode h2,
#subjectBulkMode h2 {
  margin: 0 42px 18px 0;
}

#modalInput {
  margin-top: 0;
}

#modalConfirm {
  width: 100%;
  margin-top: 12px;
}

.subject-actions {
  gap: 8px;
  margin-top: 18px;
}

.subject-actions button {
  background: var(--toggle-bg);
  color: var(--text);
  box-shadow: none;
}

.subject-actions button:hover {
  background: var(--accent-soft);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
}

#subjectEditSave,
#subjectBulkSave,
#saveSchool,
#saveAppSettings,
#customSave,
#modalConfirm {
  background: var(--accent);
  color: var(--bg);
  border-color: transparent;
}

.subject-bulk-help {
  max-width: none;
  margin: -8px 0 16px;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
}

.subject-bulk-list {
  gap: 8px;
  max-height: min(52vh, 470px);
  padding-right: 4px;
}

.subject-bulk-row {
  grid-template-columns: 102px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
}

.subject-bulk-day {
  justify-content: flex-start;
  padding: 0 12px;
  border-radius: 14px;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: left;
}

.subject-bulk-fields {
  gap: 8px;
}

.custom-panel {
  padding: 20px;
  border-radius: 22px;
  box-shadow: none;
}

.custom-panel-header {
  align-items: flex-start;
  margin-bottom: 16px;
}

.custom-panel h2 {
  margin-bottom: 6px;
}

.custom-panel p {
  font-size: 0.84rem;
  font-weight: 500;
}

.custom-close {
  flex-basis: 34px;
}

#customTimetableInput,
#memoInput,
#subjectMemo {
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.meal-list {
  gap: 10px;
}

.meal-card {
  padding: 16px;
  border-radius: 18px;
}

.tool-menu-panel {
  padding: 7px;
  border-radius: 18px;
}

.tool-menu-panel button {
  min-height: 40px;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 500;
}

@keyframes tileDialogEnter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 768px) {
  .setup-modal,
  .overlay {
    padding: 12px;
  }

  .setup-card,
  .subject-modal {
    width: min(94vw, 520px);
    max-height: 88dvh;
    padding: 20px;
    border-radius: 22px;
  }

  .selected-school-info {
    grid-template-columns: minmax(0, .72fr) minmax(0, 1.5fr) minmax(0, 1.35fr);
  }

  .selected-school-info div,
  .selected-school-info div:nth-child(2) {
    padding: 0 10px;
    border-top: 0;
    border-left: 1px solid var(--border);
  }

  .selected-school-info div:first-child {
    padding-left: 0;
    border-left: 0;
  }

  .selected-school-info div:last-child {
    padding-right: 0;
  }

  .selected-school-info strong,
  .selected-school-info div:nth-child(2) strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .subject-actions {
    grid-template-columns: 1fr;
  }

  .subject-bulk-row,
  .subject-bulk-fields {
    grid-template-columns: 1fr;
  }

  .subject-bulk-day {
    min-height: 36px;
  }

  #modalInfoMode {
    padding-inline: 24px;
  }
}

@media (max-width: 430px) {
  .setup-card,
  .subject-modal {
    width: calc(100vw - 24px);
    padding: 18px;
  }

  .setup-row {
    grid-template-columns: 1fr 1fr;
  }

  .setup-header h2,
  .subject-modal h2,
  .custom-panel h2 {
    font-size: 1.08rem;
  }

  #closeModal {
    top: 14px;
    right: 14px;
  }
}

/* Settings and editing UX */

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10000;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform 180ms ease-out;
}

.skip-link:focus {
  transform: translateY(0);
}

.dialog-eyebrow,
.modal-grabber {
  display: none;
}

.setup-modal,
.overlay {
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(8px) saturate(0.96);
  -webkit-backdrop-filter: blur(8px) saturate(0.96);
}

.setup-card,
.subject-modal {
  background: rgba(10, 10, 10, 0.97);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow:
    0 28px 72px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

body.light-mode .setup-modal,
body.light-mode .overlay {
  background: rgba(17, 24, 39, 0.26);
}

body.light-mode .setup-card,
body.light-mode .subject-modal {
  background: rgba(255, 255, 255, 0.97);
  border-color: rgba(17, 24, 39, 0.1);
  box-shadow:
    0 28px 72px rgba(15, 23, 42, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.setup-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.setup-progress > span {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1;
  transition: background-color 220ms ease, color 220ms ease;
}

.setup-progress b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--toggle-bg);
  color: var(--text-soft);
  font-size: 0.68rem;
  transition: background-color 220ms ease, color 220ms ease;
}

.setup-progress > span.is-complete b {
  background: var(--text-soft);
  color: var(--bg);
}

.setup-progress > span.is-active {
  background: var(--accent-soft);
  color: var(--text);
}

.setup-progress > span.is-active b {
  background: var(--accent);
  color: var(--bg);
}

.sync-preview {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

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

.sync-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sync-preview-heading strong {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.sync-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.sync-preview-grid > div,
.settings-data-summary > div {
  min-width: 0;
  padding: 10px;
  border-radius: 11px;
  background: var(--toggle-bg);
}

.sync-preview-grid span,
.settings-data-summary span {
  display: block;
  margin-bottom: 4px;
  color: var(--text-soft);
  font-size: 0.68rem;
  font-weight: 600;
}

.sync-preview-grid strong,
.settings-data-summary strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-preview p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.5;
}

.form-message {
  min-height: 1.2em;
  margin: -4px 0 0;
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 550;
  line-height: 1.4;
}

#schoolFormMessage {
  font-weight: 450;
}

.form-message.is-error {
  color: #ff6b65;
}

#schoolResults {
  gap: 7px;
  margin-top: -4px;
  padding: 2px;
}

#schoolResults > button {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 160ms ease-out,
    border-color 160ms ease-out,
    transform 160ms ease-out;
}

#schoolResults > button strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#schoolResults > button span {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#schoolResults > button:hover,
#schoolResults > button:focus-visible {
  border-color: var(--focus-glow-soft);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

#schoolResults > button:active {
  transform: scale(0.985);
}

.button-progress {
  display: none;
}

.settings-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border-radius: 14px;
  background: var(--surface-soft);
}

.status-layout-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.status-layout-options > button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 220ms ease, background 220ms ease, box-shadow 220ms ease;
}

.status-layout-options > button:hover {
  border-color: color-mix(in srgb, var(--text) 24%, var(--border));
  background: var(--toggle-bg);
}

.status-layout-options > button:active {
  transform: scale(0.985);
}

.status-layout-options > button.is-selected {
  border-color: color-mix(in srgb, var(--text) 38%, var(--border));
  background: var(--toggle-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 8px 24px rgba(0, 0, 0, 0.08);
}

.status-layout-options strong {
  margin-top: 12px;
  font-size: 0.88rem;
  font-weight: 650;
}

.status-layout-options small {
  margin-top: 5px;
  color: var(--text-soft);
  font-size: 0.74rem;
  line-height: 1.5;
}

.status-layout-preview {
  display: grid;
  width: 100%;
  height: 45px;
  gap: 4px;
  padding: 7px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-strong) 84%, transparent);
}

.status-layout-preview i {
  display: block;
  border-radius: 3px;
  background: color-mix(in srgb, var(--text) 18%, transparent);
}

.status-layout-preview-aligned {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.status-layout-preview-focused {
  grid-template: 2fr 1fr / repeat(6, minmax(0, 1fr));
}

.status-layout-preview-focused i:nth-child(-n + 3) { grid-column: span 2; }
.status-layout-preview-focused i:nth-child(n + 4) { grid-column: span 3; opacity: 0.62; }

.status-layout-note {
  margin-top: 12px;
}

.settings-nav button,
.secondary-action {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.settings-nav button.is-active {
  border-color: var(--border);
  background: var(--toggle-bg);
  color: var(--text);
}

.settings-section[hidden] {
  display: none;
}

.account-notice[hidden],
.account-state[hidden],
.account-confirm-panel[hidden] {
  display: none;
}

.settings-card > .setup-actions[hidden] {
  display: none;
}

.settings-data-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.settings-secondary-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.settings-secondary-actions .secondary-action {
  border-color: var(--border);
  background: var(--toggle-bg);
  color: var(--text);
}

.share-card {
  width: min(960px, calc(100vw - 32px));
  max-height: min(880px, calc(100dvh - 32px));
  overflow: auto;
  scrollbar-width: thin;
}

.share-card .setup-header h2 {
  font-weight: 600;
  font-variation-settings: "wght" 600;
}

.share-card :is(strong, legend, button) {
  font-weight: 550;
  font-variation-settings: "wght" 550;
}

.share-mode-panel { display: grid; gap: 14px; }
.share-mode-panel[hidden], .share-draft-editor[hidden], .shared-memo-view[hidden], .shared-showcase-description[hidden] { display: none; }

.share-scope-fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.share-scope-fieldset legend { margin-bottom: 9px; color: var(--text); font-size: 0.78rem; font-weight: 550; }
.share-scope-fieldset label {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 13px 14px;
  border-radius: 16px;
  background: var(--surface-soft);
  cursor: pointer;
  transition: transform 150ms ease, background-color 180ms ease;
}
.share-scope-fieldset label:active { transform: scale(0.985); }
.share-scope-fieldset input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.share-scope-fieldset label span { display: grid; gap: 3px; min-width: 0; }
.share-scope-fieldset strong { color: var(--text); font-size: 0.78rem; }
.share-scope-fieldset small { color: var(--text-soft); font-size: 0.68rem; line-height: 1.35; }

.share-draft-controls, .share-manager-header, .share-showcase-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface-soft));
}
.share-draft-controls > div, .share-manager-header > div, .share-showcase-heading > div { display: grid; gap: 4px; min-width: 0; }
.share-draft-controls strong, .share-manager-header strong, .share-showcase-heading strong { color: var(--text); font-size: 0.86rem; letter-spacing: -0.018em; }
.share-draft-controls span, .share-manager-header span, .share-showcase-heading span { color: var(--text-soft); font-size: 0.7rem; line-height: 1.45; }

.share-draft-editor {
  display: grid;
  gap: 12px;
  padding: 15px;
  border-radius: 20px;
  background: var(--surface-soft);
}
.share-draft-editor-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.share-draft-editor-header strong { color: var(--text); font-size: 0.82rem; }
.share-draft-editor > p { margin: 0; color: var(--text-soft); font-size: 0.68rem; line-height: 1.5; }
.share-draft-grid { display: grid; gap: 12px; max-height: 420px; overflow: auto; padding: 2px; scrollbar-width: thin; }
.share-draft-period { display: grid; gap: 8px; }
.share-draft-period-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-inline: 3px; }
.share-draft-period-heading strong { color: var(--text); font-size: 0.75rem; }
.share-draft-period-heading span { color: var(--text-soft); font-size: 0.64rem; }
.share-draft-days { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 3px; }
.share-draft-cell { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; min-width: 0; padding: 11px; border-radius: 15px; background: var(--surface); }
.share-draft-cell > strong { grid-column: 1 / -1; color: var(--accent); font-size: 0.68rem; }
.share-draft-field { display: grid; gap: 4px; min-width: 0; }
.share-draft-field.is-wide { grid-column: 1 / -1; }
.share-draft-field span { color: var(--text-soft); font-size: 0.59rem; }
.share-draft-field input { width: 100%; box-sizing: border-box; min-width: 0; padding: 8px 9px; border: 0; border-radius: 10px; outline: 1px solid transparent; background: var(--toggle-bg); color: var(--text); font: inherit; font-size: 0.68rem; transition: outline-color 160ms ease, background-color 160ms ease; }
.share-draft-field input:focus { outline-color: color-mix(in srgb, var(--accent) 52%, transparent); background: var(--surface); }

.share-readonly-badge { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent) !important; font-weight: 550; }
.share-beta-badge { display: inline-flex; margin-left: 5px; padding: 2px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.58rem; font-weight: 550; letter-spacing: 0; vertical-align: 1px; }
.share-preview-state { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 5px 7px; min-width: 0; padding: 10px 13px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 7%, var(--surface-soft)); color: var(--text); }
.share-preview-state > span { grid-row: 1 / 3; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.share-preview-state strong { font-size: 0.69rem; letter-spacing: -0.012em; }
.share-preview-state small { color: var(--text-soft); font-size: 0.64rem; }
.share-viewer-actions { grid-template-columns: minmax(0, .8fr) minmax(0, .8fr) minmax(0, 1.25fr); }
.shared-showcase-description { margin: 0; padding: 2px 4px; color: var(--text-soft); font-size: 0.76rem; line-height: 1.65; white-space: pre-wrap; }
.shared-timetable-view { min-height: 160px; }
.shared-timetable-scroll { overflow: auto; border-radius: 18px; background: var(--surface-soft); scrollbar-width: thin; }
.shared-timetable-scroll table { width: 100%; min-width: 760px; border-collapse: separate; border-spacing: 6px; padding: 8px; table-layout: fixed; }
.shared-timetable-scroll th, .shared-timetable-scroll td { padding: 10px; border: 0; border-radius: 12px; text-align: left; vertical-align: top; }
.shared-timetable-scroll thead th { color: var(--text-soft); background: transparent; font-size: 0.66rem; text-align: center; }
.shared-timetable-scroll tbody th { width: 98px; background: var(--toggle-bg); }
.shared-timetable-scroll tbody th strong, .shared-timetable-scroll tbody th span { display: block; }
.shared-timetable-scroll tbody th strong { color: var(--text); font-size: 0.7rem; }
.shared-timetable-scroll tbody th span { margin-top: 4px; color: var(--text-soft); font-size: 0.56rem; line-height: 1.35; }
.shared-timetable-scroll td { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.shared-timetable-scroll td > strong, .shared-timetable-scroll td > span, .shared-timetable-scroll td > small { display: block; overflow-wrap: anywhere; }
.shared-timetable-scroll td > strong { color: var(--text); font-size: 0.7rem; line-height: 1.35; }
.shared-timetable-scroll td > span { margin-top: 5px; color: var(--text-soft); font-size: 0.58rem; line-height: 1.35; }
.shared-timetable-scroll td > small { margin-top: 7px; color: var(--accent); font-size: 0.57rem; line-height: 1.4; }
.shared-timetable-scroll .shared-empty-cell { background: transparent; }
.shared-timetable-scroll .shared-special-cell {
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 0.7rem;
  font-weight: 550;
  line-height: 1.35;
  letter-spacing: -0.012em;
  font-variation-settings: "wght" 550;
  text-align: center;
  vertical-align: middle;
}
.shared-memo-view { padding: 14px 16px; border-radius: 16px; background: var(--surface-soft); color: var(--text-soft); font-size: 0.72rem; line-height: 1.6; white-space: pre-wrap; }

.share-manager-list { display: grid; gap: 8px; }
.share-manager-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; border-radius: 16px; background: var(--surface-soft); }
.share-manager-item.is-disabled { opacity: 0.62; }
.share-manager-item > div:first-child { display: grid; gap: 4px; min-width: 0; }
.share-manager-item strong, .share-manager-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-manager-item strong { color: var(--text); font-size: 0.78rem; }
.share-manager-item span { color: var(--text-soft); font-size: 0.66rem; }
.share-manager-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.share-manager-actions button { min-height: 36px; padding: 8px 11px; }
.share-manager-empty { padding: 36px 20px; color: var(--text-soft); font-size: 0.75rem; text-align: center; }

@media (max-width: 680px) {
  .share-scope-fieldset { grid-template-columns: 1fr; }
  .share-draft-controls, .share-manager-header, .share-manager-item { align-items: stretch; flex-direction: column; }
  .share-draft-controls button, .share-manager-header button { width: 100%; }
  .share-manager-actions { justify-content: stretch; }
  .share-manager-actions button { flex: 1 1 auto; }
  .share-viewer-actions { grid-template-columns: 1fr 1fr; }
  .share-viewer-actions .primary-action { grid-column: 1 / -1; }
}

.share-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.share-preview > div {
  min-width: 0;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-soft);
}

.share-preview span,
.share-preview strong {
  display: block;
}

.share-preview span {
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: 0.68rem;
  font-weight: 550;
}

.share-preview strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.83rem;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-privacy-note {
  padding: 2px;
  border: 0;
  background: transparent;
}

.share-privacy-notes {
  display: grid;
  gap: 3px;
  margin-top: -7px;
}

.share-privacy-note strong {
  display: inline;
  margin: 0;
  color: var(--text);
  font-size: 0.8rem;
  letter-spacing: -0.025em;
}

.share-privacy-note p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.72rem;
  line-height: 1.55;
}

/* Keep native controls on the same locally bundled typeface as the page. */
button, input, textarea, select, option {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

.share-card :is(input, textarea) {
  font-weight: 500;
  font-variation-settings: normal;
}

.share-beta-badge,
.share-readonly-badge,
.tool-menu-panel .tool-beta-badge {
  border-radius: 5px;
  font-variation-settings: "wght" 550;
}

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

.share-link-field input {
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-actions {
  grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
}

.share-actions.is-receive {
  grid-template-columns: 1fr;
}

.share-actions > button:active {
  transform: scale(0.975);
}

.share-create-action {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  color: #171717;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.share-create-action:hover {
  background: #f7f7f7;
  border-color: rgba(0, 0, 0, 0.14);
}

.share-result-link input[readonly] {
  cursor: text;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 520;
}

.account-state {
  display: grid;
  gap: 12px;
}

.account-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
}

.account-identity > div { display: grid; gap: 3px; min-width: 0; }
.account-identity strong,
.account-identity span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-identity strong { color: var(--text); font-size: 0.9rem; font-weight: 600; }
.account-identity div span { color: var(--text-soft); font-size: 0.74rem; }

.account-brand-logo {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.account-provider-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: -4px 0 0;
  color: var(--text-soft);
  font-size: 0.68rem;
  line-height: 1.4;
}

.account-provider-note .google-mark {
  width: 13px;
  height: 13px;
}

.account-lightframe-action {
  position: relative;
  z-index: 0;
  display: grid;
}

.account-lightframe-action::before {
  position: absolute;
  z-index: -1;
  inset: -6px;
  border-radius: 18px;
  background: linear-gradient(90deg, #008469 0%, #064a9c 10%, #1600cf 22%, #7400f2 48%, #a810e8 65%, #ec58cd 79%, #f3a38e 90%, #f8e36d 100%);
  filter: blur(12px) saturate(1.22) brightness(1.08);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.97);
  transition: opacity 180ms ease, transform 220ms ease;
  content: "";
}

.account-lightframe-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 14px 44px;
  overflow: hidden;
  isolation: isolate;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(90deg, #008469 0%, #064a9c 10%, #1600cf 22%, #7400f2 48%, #a810e8 65%, #ec58cd 79%, #f3a38e 90%, #f8e36d 100%);
  background-clip: border-box;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  color: #faf9fc;
  font: inherit;
  cursor: pointer;
  transition: filter 160ms ease, box-shadow 160ms ease;
}

.account-lightframe-mark { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 20px; width: 20px; height: 20px; margin-right: 8px; font-size: 18px; line-height: 1; }
.account-lightframe-label { display: inline-flex; align-items: baseline; gap: 5px; }
.account-lightframe-label strong { font-size: 1rem; font-weight: 650; letter-spacing: -0.035em; line-height: 1.1; }
.account-lightframe-label > span { color: #faf9fc; font-size: 0.79rem; font-weight: 500; line-height: 1.5; }
@media (hover: hover) {
  .account-lightframe-toggle:hover:not(:disabled) {
    filter: brightness(1.1) saturate(1.06);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
  }
  .account-lightframe-action:hover::before {
    opacity: 0.88;
    transform: scale(1);
  }
}
.account-lightframe-action:focus-within::before,
.account-lightframe-action:active::before {
  opacity: 0.88;
  transform: scale(1);
}
.account-lightframe-toggle:active { transform: scale(0.985); filter: brightness(0.93); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); transition: none; }
.account-lightframe-toggle:focus-visible { outline: 3px solid #aa8fe7; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  .account-lightframe-toggle { transition: opacity 150ms ease; }
  .account-lightframe-action::before { transition: opacity 150ms ease; transform: none; }
  .account-lightframe-toggle:active { transform: none; opacity: 0.8; }
  .setup-progress > span,
  .setup-progress b { transition: opacity 150ms ease; }
}

.account-email-form {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.account-email-form[hidden] { display: none; }
.account-email-intro {
  margin: 0 0 2px;
  color: var(--text-muted);
  font-size: 0.73rem;
  font-weight: 500;
  line-height: 1.45;
}
.account-email-form .setup-field { gap: 5px; }
.account-email-form input {
  width: 100%;
  min-height: 42px;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: 0;
  background: var(--toggle-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
}

.account-email-form input:focus {
  border-color: var(--focus-glow);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--focus-glow-soft);
}

.account-email-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.account-email-actions button {
  min-height: 40px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
}

.account-email-actions .primary-action {
  border: 0;
  background: var(--accent);
  color: var(--bg);
}

.account-email-message {
  min-height: 1.35em;
  margin: 0;
  color: var(--text-soft);
  font-size: 0.7rem;
  line-height: 1.45;
}

.account-email-message[data-tone="error"] { color: #ff5a5f; }
.account-email-message[data-tone="success"] { color: #34c759; }

.account-avatar {
  display: inline-flex;
  flex: 0 0 40px;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
}

.account-primary-action,
.account-text-action,
.account-confirm-panel button { border: 0; font: inherit; cursor: pointer; }

.account-primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid #747775;
  border-radius: 12px;
  background: #fff;
  color: #1f1f1f;
  box-shadow: 0 1px 2px rgba(31, 31, 31, 0.08);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: -0.012em;
  font-variation-settings: "wght" 600;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 120ms ease;
}

.google-mark {
  display: block;
  width: 18px;
  height: auto;
  flex: 0 0 18px;
  object-fit: contain;
}

@media (hover: hover) {
  .account-primary-action:hover:not(:disabled) { background: #f8faff; border-color: #5f6368; box-shadow: 0 2px 5px rgba(31, 31, 31, 0.16); }
}
.account-primary-action:active:not(:disabled) { box-shadow: inset 0 1px 3px rgba(31, 31, 31, 0.14); transition: none; }
.account-primary-action:focus-visible { outline: 3px solid rgba(66, 133, 244, 0.24); outline-offset: 2px; }

.account-primary-action:active,
.account-text-action:active,
.account-confirm-panel button:active { transform: scale(0.975); }

.account-primary-action:disabled,
.account-actions button:disabled,
.account-confirm-panel button:disabled { cursor: wait; opacity: 0.55; }

.account-notice {
  display: grid;
  gap: 5px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.account-notice strong { color: var(--text); font-size: 0.84rem; }
.account-notice span { color: var(--text-soft); font-size: 0.74rem; line-height: 1.5; }
.account-summary { padding: 0; }
.account-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.account-message { min-height: 0; margin: 0; }
.account-message[data-tone="error"] { color: #ff5a5f; }
.account-message[data-tone="success"] { color: #34c759; }

.account-text-action {
  justify-self: start;
  padding: 4px 2px;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 600;
}

.account-danger-action,
.account-danger-panel strong { color: #ff5a5f; }

.account-confirm-panel {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.account-confirm-panel strong { color: var(--text); font-size: 0.82rem; }
.account-confirm-panel p { margin: 0; color: var(--text-soft); font-size: 0.74rem; line-height: 1.5; }
.account-confirm-panel > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.account-confirm-panel button { min-height: 38px; border-radius: 10px; font-size: 0.78rem; font-weight: 600; }
.account-confirm-panel .primary-action { background: var(--accent); color: #fff; }
.account-confirm-panel .danger-action { background: #ff453a; color: #fff; }

.tile-reset-section {
  display: grid;
  justify-items: start;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  background: linear-gradient(90deg, var(--border), transparent) top / 100% 1px no-repeat;
}
.tile-reset-section .account-confirm-panel { width: 100%; }
.tile-reset-section .account-danger-action { min-height: 40px; padding-inline: 8px; }
.tile-reset-section .account-danger-action:hover { color: #ff8780; }
.tile-reset-section .account-danger-action:active { transform: scale(.98); }
.tile-reset-section .danger-action:disabled { cursor: not-allowed; opacity: .48; }

@media (max-width: 560px) {
  .account-actions,
  .account-confirm-panel > div { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .account-primary-action,
  .account-text-action,
  .account-confirm-panel button { transition: opacity 150ms ease; }

  .account-primary-action:active,
  .account-text-action:active,
  .account-confirm-panel button:active { transform: none; opacity: 0.72; }
}

.tool-menu-panel .tool-menu-label {
  display: block;
  padding: 8px 10px 4px;
  color: var(--text-soft);
  font-size: 0.65rem;
  font-weight: 600;
}

.tool-menu-panel .tool-menu-label-help,
.tool-menu-panel .tool-menu-label-pending {
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.tool-menu-panel .tool-menu-unavailable {
  opacity: 0.42;
}

.tool-menu-panel button {
  display: grid;
  gap: 2px;
  text-align: left;
}

.tool-menu-panel button span {
  color: var(--text);
  font-size: inherit;
  font-weight: inherit;
}

.tool-menu-panel .tool-menu-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-menu-panel .tool-beta-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.56rem;
  font-style: normal;
  font-weight: 550;
  letter-spacing: 0;
  line-height: 1.2;
}

.feature-stage-badge,
.management-studio-action .feature-stage-badge {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 4px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.6rem;
  font-style: normal;
  font-weight: 550;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: nowrap;
}

.timetable-actions .feature-stage-badge { margin-left: 5px; }

.tool-menu-panel button small {
  color: var(--text-soft);
  font-size: 0.68rem;
  font-weight: 500;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--toggle-bg);
  color: var(--text-soft);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.source-badge::before {
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  opacity: 0.7;
}

.source-neis {
  color: #79aefb;
}

.source-local {
  color: #6fd9aa;
}

.subject-editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-right: 42px;
}

.subject-editor-heading h2 {
  margin-right: 0 !important;
}

.subject-edit-context {
  margin: -10px 0 16px !important;
  color: var(--text-soft) !important;
  font-size: 0.78rem !important;
  font-weight: 500 !important;
  text-align: left !important;
}

.subject-form-grid,
.subject-bulk-common {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.subject-form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.subject-form-field > span {
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.25;
}

.subject-form-wide {
  grid-column: 1 / -1;
}

.subject-form-field input,
.subject-form-field select,
.subject-form-field textarea,
.period-time-grid input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
  outline: none;
}

.subject-form-field textarea {
  min-height: 92px;
  resize: vertical;
}

.subject-form-field input:focus,
.subject-form-field select:focus,
.subject-form-field textarea:focus,
.period-time-grid input:focus {
  border-color: var(--focus-glow);
  box-shadow: 0 0 0 3px var(--focus-glow-soft);
}

.subject-bulk-common {
  margin-bottom: 14px;
}

.subject-bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.subject-bulk-toolbar strong {
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 600;
}

.subject-bulk-toolbar button {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

.subject-bulk-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
}

.subject-bulk-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent);
}

.subject-bulk-day {
  display: grid;
  gap: 3px;
}

.subject-bulk-day strong {
  color: var(--text);
  font-size: 0.78rem;
}

.subject-bulk-day span,
.subject-bulk-meta {
  color: var(--text-soft);
  font-size: 0.7rem;
}

.subject-bulk-meta {
  text-align: right;
}

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

#periodEditMode {
  min-height: 0;
  padding-top: 2px;
}

#periodEditMode h2 {
  margin: 0 42px 18px 0;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 12000;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}

.tile-toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  animation: tileToastIn 220ms ease-out both;
}

.tile-toast > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.tile-toast strong {
  font-size: 0.82rem;
  font-weight: 600;
}

.tile-toast span {
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.4;
}

.tile-toast button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--toggle-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

.tile-toast.is-leaving {
  animation: tileToastOut 220ms ease-out both;
}

button:active,
.theme-toggle:active,
.dialog-close:active {
  transform: scale(0.97);
}

.demo-launch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
}

.feedback-dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  padding: 26px;
  box-sizing: border-box;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--shadow);
}
.feedback-dialog::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(10px); }
.feedback-dialog form { display: grid; gap: 18px; }
.feedback-dialog .setup-header { margin: 0; }
.feedback-dialog h2 { margin: 4px 0 0; font-size: 1.4rem; line-height: 1.15; letter-spacing: -.025em; }
.feedback-types { display: flex; gap: 8px; padding: 0; margin: 0; border: 0; }
.feedback-types legend { margin-bottom: 10px; color: var(--text-soft); font-size: .85rem; }
.feedback-types label { position: relative; flex: 1; cursor: pointer; }
.feedback-types input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.feedback-types span { display: block; padding: 12px 8px; border-radius: 12px; background: var(--toggle-bg); text-align: center; font-size: .9rem; }
.feedback-types input:checked + span { background: var(--accent); color: var(--bg); }
.feedback-types input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.feedback-types label:active span { opacity: .7; }
#feedbackBugFields { display: grid; gap: 16px; }
#feedbackBugFields[hidden] { display: none; }
.feedback-dialog textarea { min-height: 90px; resize: vertical; }
.feedback-privacy { margin: 0; color: var(--text-soft); font-size: .8rem; line-height: 1.6; }
.feedback-dialog .form-message { margin: 0; line-height: 1.6; }
.feedback-submit { min-height: 44px; padding: 12px 16px; border: 0; border-radius: 12px; background: var(--accent); color: var(--bg); font: inherit; font-size: .9rem; cursor: pointer; }
.feedback-submit:active { opacity: .75; }
.feedback-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.demo-launch > span {
  font-size: 0.68rem;
  transform: translateX(1px);
}

.tile-demo {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  overflow: hidden;
  background: rgba(2, 3, 8, 0.78);
  backdrop-filter: blur(0) saturate(1);
  -webkit-backdrop-filter: blur(0) saturate(1);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 360ms ease, backdrop-filter 500ms ease, visibility 0s linear 500ms;
}

.tile-demo.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  backdrop-filter: blur(28px) saturate(1.16);
  -webkit-backdrop-filter: blur(28px) saturate(1.16);
  transition-delay: 0s;
}

.tile-demo-aurora {
  position: absolute;
  width: min(90vw, 900px);
  aspect-ratio: 1.7;
  border-radius: 50%;
  background: radial-gradient(circle at 24% 48%, rgba(0, 170, 255, 0.28), transparent 34%), radial-gradient(circle at 70% 52%, rgba(137, 50, 255, 0.3), transparent 40%);
  filter: blur(54px);
  opacity: 0.7;
  transform: translate3d(-4%, 8%, 0) scale(0.92);
  transition: transform 1.4s cubic-bezier(.2,.8,.2,1), opacity 600ms ease;
}

.tile-demo.is-open .tile-demo-aurora { opacity: 1; transform: translate3d(4%, -2%, 0) scale(1.05); }

.tile-demo-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1040px, 100%);
  height: min(720px, calc(100dvh - 36px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-top-color: rgba(255, 255, 255, 0.3);
  border-radius: 30px;
  background: rgba(10, 11, 17, 0.82);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: #fff;
  opacity: 0;
  transform: scale(0.96) translateY(14px);
  transition: opacity 420ms ease, transform 620ms cubic-bezier(.16,1,.3,1);
}

.tile-demo.is-open .tile-demo-shell { opacity: 1; transform: scale(1) translateY(0); }
.tile-demo-topbar, .tile-demo-footer { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 22px 26px; }
.tile-demo-brand { font-size: 1.05rem; font-weight: 720; letter-spacing: -0.04em; }
.tile-demo-icon-button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; background: rgba(255,255,255,.08); color: #fff; font: 300 1.45rem/1 sans-serif; cursor: pointer; backdrop-filter: blur(14px); }
.tile-demo-icon-button:active { transform: scale(.92); }

.tile-demo-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  align-items: center;
  gap: clamp(28px, 5vw, 68px);
  min-height: 0;
  padding: 10px clamp(30px, 6vw, 72px) 28px;
}

.tile-demo-visual {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 380px;
  perspective: 1000px;
}

.tile-demo-visual > * { animation: demoVisualIn 700ms cubic-bezier(.16,1,.3,1) both; }
.tile-demo-copy > * { animation: demoCopyIn 620ms cubic-bezier(.16,1,.3,1) both; }
.tile-demo-copy > :nth-child(2) { animation-delay: 70ms; }
.tile-demo-copy > :nth-child(3) { animation-delay: 130ms; }
.tile-demo-eyebrow { display: block; margin-bottom: 14px; color: #9cbcff; font-size: .74rem; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; }
.tile-demo-copy h2 { max-width: 430px; margin: 0; font-size: clamp(2.2rem, 4.5vw, 4.25rem); font-weight: 650; letter-spacing: -.055em; line-height: 1.02; }
.tile-demo-copy p { max-width: 390px; margin: 20px 0 0; color: rgba(255,255,255,.64); font-size: clamp(.98rem, 1.6vw, 1.12rem); line-height: 1.65; word-break: keep-all; }

.demo-device {
  position: relative;
  width: min(100%, 470px);
  min-height: 330px;
  padding: 22px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.18);
  border-top-color: rgba(255,255,255,.34);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(255,255,255,.13), rgba(255,255,255,.045));
  box-shadow: 0 32px 70px rgba(0,0,0,.38), inset 0 1px 0 rgba(255,255,255,.08);
  transform: rotateY(5deg) rotateX(2deg);
  backdrop-filter: blur(22px);
}

.demo-device-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; color: rgba(255,255,255,.55); font-size: .72rem; }
.demo-device-head strong { color: #fff; font-size: 1rem; letter-spacing: -.03em; }
.demo-now { display: grid; gap: 8px; padding: 22px; border-radius: 20px; background: rgba(82,73,255,.19); box-shadow: inset 0 0 0 1px rgba(152,162,255,.24); }
.demo-now span, .demo-mini-card span, .demo-sync-card span { color: rgba(255,255,255,.54); font-size: .72rem; }
.demo-now strong { font-size: clamp(1.35rem, 3vw, 2rem); letter-spacing: -.045em; }
.demo-now time { color: #aeb8ff; font-size: .86rem; font-weight: 650; }
.demo-status-row { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin-top: 10px; }
.demo-mini-card { display: grid; gap: 6px; padding: 14px; border-radius: 16px; background: rgba(255,255,255,.07); }
.demo-mini-card strong { font-size: .9rem; }

.demo-timetable { display: grid; grid-template-columns: 44px repeat(5,1fr); gap: 7px; width: min(100%, 480px); padding: 18px; border: 1px solid rgba(255,255,255,.16); border-radius: 24px; background: rgba(255,255,255,.065); box-shadow: 0 28px 64px rgba(0,0,0,.34); transform: rotateX(6deg) rotateZ(-1deg); }
.demo-timetable span { display: grid; place-items: center; min-height: 42px; padding: 6px; border-radius: 10px; background: rgba(255,255,255,.06); color: rgba(255,255,255,.62); font-size: .66rem; text-align: center; }
.demo-timetable .is-live { background: linear-gradient(135deg, #3f42ff, #8a38f5); color: #fff; box-shadow: 0 8px 20px rgba(88,64,255,.38); animation: demoTilePulse 1.8s ease-in-out infinite; }

.demo-stack { position: relative; width: min(100%, 460px); height: 340px; }
.demo-panel { position: absolute; display: grid; gap: 12px; width: 72%; padding: 22px; border: 1px solid rgba(255,255,255,.17); border-radius: 24px; background: rgba(22,24,34,.84); box-shadow: 0 24px 60px rgba(0,0,0,.36); backdrop-filter: blur(20px); }
.demo-panel:first-child { top: 24px; left: 0; transform: rotate(-3deg); }
.demo-panel:last-child { right: 0; bottom: 18px; transform: rotate(3deg); }
.demo-panel small { color: #9cbcff; font-weight: 650; }
.demo-panel strong { font-size: 1.18rem; letter-spacing: -.03em; }
.demo-panel p { margin: 0; color: rgba(255,255,255,.58); font-size: .78rem; line-height: 1.5; }

.demo-sync { display: grid; place-items: center; width: min(100%, 470px); min-height: 360px; }
.demo-sync-orbit { position: relative; display: grid; place-items: center; width: 260px; height: 260px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 80px rgba(100,62,255,.25); }
.demo-sync-orbit::before, .demo-sync-orbit::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; }
.demo-sync-orbit::before { inset: 28px; }
.demo-sync-orbit::after { inset: 58px; }
.demo-sync-card { position: relative; z-index: 1; display: grid; justify-items: center; gap: 8px; padding: 22px 28px; border-radius: 22px; background: linear-gradient(120deg,#0c72a8,#4d20e7 43%,#dc35d0 76%,#f3d86a); box-shadow: 0 20px 55px rgba(109,54,255,.4), inset 0 0 0 1px rgba(255,255,255,.25); }
.demo-sync-card b { font-size: 1.7rem; }
.demo-sync-card strong { font-size: 1rem; }

.tile-demo-footer { gap: 20px; padding-top: 12px; }
.tile-demo-progress { display: flex; flex: 1; gap: 7px; max-width: 440px; }
.tile-demo-progress button { position: relative; flex: 1; height: 3px; padding: 0; overflow: hidden; border: 0; border-radius: 999px; background: rgba(255,255,255,.18); cursor: pointer; }
.tile-demo-progress button::after { content: ""; position: absolute; inset: 0; background: #fff; transform: scaleX(0); transform-origin: left; }
.tile-demo-progress button.is-complete::after { transform: scaleX(1); }
.tile-demo-progress button.is-current::after { animation: demoProgress var(--demo-duration, 5200ms) linear forwards; animation-play-state: var(--demo-play-state, running); }
.tile-demo-controls { display: flex; align-items: center; gap: 8px; }
.tile-demo-text-button, .tile-demo-next { min-height: 38px; padding: 8px 12px; border-radius: 999px; color: #fff; font: inherit; font-size: .76rem; font-weight: 600; cursor: pointer; }
.tile-demo-text-button { border: 0; background: transparent; color: rgba(255,255,255,.64); }
.tile-demo-next { min-width: 66px; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.1); backdrop-filter: blur(12px); }
.tile-demo-text-button:hover { color: #fff; }
.tile-demo-next:hover { background: rgba(255,255,255,.16); }
body.tile-demo-open { overflow: hidden; }

@keyframes demoVisualIn { from { opacity: 0; transform: translate3d(0,22px,0) scale(.96); filter: blur(10px); } to { opacity: 1; transform: translate3d(0,0,0) scale(1); filter: blur(0); } }
@keyframes demoCopyIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes demoTilePulse { 50% { filter: brightness(1.25); box-shadow: 0 10px 28px rgba(88,64,255,.62); } }
@keyframes demoProgress { to { transform: scaleX(1); } }

@media (max-width: 760px) {
  .tile-demo-shell { border-radius: 24px; }
  .tile-demo-stage { grid-template-columns: 1fr; align-content: center; gap: 20px; padding: 0 24px 16px; }
  .tile-demo-visual { min-height: 280px; }
  .demo-device { min-height: 260px; padding: 16px; }
  .demo-timetable { transform: none; }
  .demo-stack { height: 270px; }
  .demo-sync { min-height: 280px; }
  .demo-sync-orbit { width: 220px; height: 220px; }
  .tile-demo-copy { text-align: center; }
  .tile-demo-copy h2, .tile-demo-copy p { margin-left: auto; margin-right: auto; }
  .tile-demo-copy h2 { font-size: clamp(2rem, 11vw, 3.2rem); }
  .tile-demo-copy p { margin-top: 12px; font-size: .92rem; }
  .tile-demo-footer { align-items: flex-end; padding: 16px 20px 20px; }
  .tile-demo-controls { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 480px) {
  .tile-demo { padding: 0; }
  .tile-demo-shell { height: 100dvh; border: 0; border-radius: 0; }
  .tile-demo-topbar { padding: max(18px, env(safe-area-inset-top)) 20px 14px; }
  .tile-demo-stage { padding-inline: 18px; }
  .tile-demo-visual { min-height: 248px; }
  .demo-device { min-height: 230px; border-radius: 22px; }
  .demo-now { padding: 16px; }
  .demo-timetable { gap: 4px; padding: 12px; }
  .demo-timetable span { min-height: 32px; font-size: .56rem; }
  .tile-demo-footer { display: grid; }
  .tile-demo-progress { width: 100%; max-width: none; }
  .tile-demo-controls { justify-content: center; }
}

@keyframes tileToastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tileToastOut {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (max-width: 768px) {
  .subject-form-grid,
  .subject-bulk-common {
    grid-template-columns: 1fr;
  }

  .subject-form-wide {
    grid-column: auto;
  }

  .subject-bulk-row {
    grid-template-columns: 20px minmax(0, 1fr);
  }

  .subject-bulk-meta {
    grid-column: 2;
    text-align: left;
  }

  .toast-region {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(100vw - 24px);
  }
}

@media (max-width: 430px) {
  .selected-school-info {
    grid-template-columns: 72px 148px 140px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  .setup-progress > span {
    justify-content: center;
    padding: 8px 5px;
    font-size: 0.7rem;
  }

  .setup-progress b {
    display: none;
  }

  .sync-preview-grid,
  .share-preview,
  .settings-data-summary,
  .settings-secondary-actions,
  .status-layout-options {
    grid-template-columns: 1fr;
  }

  .share-actions {
    grid-template-columns: 1fr;
  }

  .period-time-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tile-toast {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skip-link,
  .tile-toast,
  .tile-toast.is-leaving,
  button {
    animation-duration: 150ms !important;
    transition-duration: 150ms !important;
  }

  .tile-toast,
  .tile-toast.is-leaving {
    transform: none;
  }

  .tile-demo,
  .tile-demo-shell,
  .tile-demo-aurora,
  .tile-demo-visual > *,
  .tile-demo-copy > * {
    animation: none !important;
    transition: opacity 150ms ease !important;
    transform: none !important;
    filter: none !important;
  }

  .tile-demo-progress button.is-current::after { animation-duration: 150ms; }
}

/* Guided tour: the live application remains visible through the spotlight. */
.tile-demo, .tile-demo.is-open {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
}
#tileDemoSpotlight {
  position: fixed;
  border-radius: 16px;
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .78), inset 0 0 0 1px rgba(255,255,255,.5);
  pointer-events: none;
}
.tile-demo .tile-demo-shell {
  position: absolute;
  inset: auto 32px max(32px, env(safe-area-inset-bottom)) auto;
  width: min(430px, calc(100% - 48px));
  height: auto;
  max-height: 46dvh;
  overflow: auto;
  border-radius: 0;
  background: transparent;
  color: #fff;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.tile-demo .tile-demo-stage { display: block; padding: 0; }
.tile-demo .tile-demo-visual { display: none; }
.tile-demo .tile-demo-copy { text-align: left; }
.tile-demo .tile-demo-copy h2 { margin: 14px 0; color: #fff; font-size: 25px; font-weight: 600; line-height: 1.15; letter-spacing: -.03em; }
.tile-demo .tile-demo-copy p { margin: 0; color: rgba(255,255,255,.8); font-size: 15px; line-height: 1.65; }
.tile-demo .tile-demo-meta { display: flex; align-items: center; justify-content: space-between; color: rgba(255,255,255,.65); font-size: 13px; }
.tile-demo .tile-demo-meta > span:last-child { font-size: 11px; font-weight: 650; letter-spacing: .04em; }
.tile-demo .tile-demo-eyebrow { margin: 0; color: inherit; font-size: inherit; letter-spacing: 0; font-weight: 500; }
.tile-demo .tile-demo-progress { width: 100%; max-width: none; height: 2px; margin-top: 11px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.18); }
.tile-demo .tile-demo-progress i { display: block; width: 100%; height: 100%; border-radius: inherit; background: #fff; transform: scaleX(0); transform-origin: left; animation: demoProgress var(--demo-duration, 2600ms) linear forwards; animation-play-state: var(--demo-play-state, running); }
.tile-demo .tile-demo-controls { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.tile-demo button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.tile-demo .tile-demo-brand { font-size: .85rem; font-weight: 600; color: var(--text-soft); letter-spacing: -.015em; }
.tile-demo .tile-demo-icon-button { color: var(--text); background: var(--toggle-bg); border-color: var(--border); }
.tile-demo .tile-demo-text-button { color: rgba(255,255,255,.7); font-size: .82rem; border-radius: 12px; }
.tile-demo .tile-demo-text-button:hover { color: #fff; background: rgba(255,255,255,.08); }
.tile-demo .tile-demo-text-button:disabled { opacity: .38; cursor: default; }
.tile-demo .tile-demo-next { border: 0; border-radius: 12px; background: transparent; color: #fff; font-size: .82rem; min-height: 40px; backdrop-filter: none; }
.tile-demo .tile-demo-next:hover { background: rgba(255,255,255,.08); }
.tile-demo .tile-demo-text-button:active,
.tile-demo .tile-demo-next:active { transform: scale(.96); opacity: .8; }
body.tile-demo-open .floating-topbar { visibility: hidden; }
.tile-demo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1800ms cubic-bezier(.4, 0, .2, 1), background-color 800ms ease;
}
.tile-demo.is-finale::after { opacity: 1; }
.tile-demo.is-finale .tile-demo-shell { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 600ms ease, visibility 0s 600ms; }
#tileDemoBegin {
  position: relative;
  z-index: 3;
  padding: 20px 28px;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: clamp(1.6rem, 5vw, 3rem);
  font-weight: 600;
  letter-spacing: -.035em;
  line-height: 1.15;
  cursor: pointer;
  animation: tileTourFinaleText 1000ms ease 1200ms both;
  text-shadow: 0 0 0 transparent;
  transition: color 600ms ease, text-shadow 280ms ease, opacity 500ms ease;
}
#tileDemoBegin[hidden] { display: none; }
#tileDemoBegin small {
  display: block;
  margin-top: 16px;
  font-size: .9rem;
  font-weight: 400;
  letter-spacing: -.01em;
  color: #929292;
  text-shadow: none;
  animation: tileTourFinaleText 1400ms ease 3200ms both;
}
@media (hover: hover) {
  #tileDemoBegin:hover { text-shadow: none; }
}
.tile-demo.is-finale.is-start-hover::after { background-color: #fff; }
.tile-demo.is-start-hover #tileDemoBegin { color: #111; text-shadow: none; }
.tile-demo.is-start-hover #tileDemoBegin small { color: #666; }
.tile-demo.is-start-leaving #tileDemoBegin { animation: none; opacity: 0; pointer-events: none; }
.tile-demo.is-start-revealing #tileDemoSpotlight { visibility: hidden; }
.tile-demo.is-start-revealing::after { opacity: 0; transition: opacity 900ms ease; }
.tile-demo.is-start-revealing { opacity: 0; transition: opacity 900ms ease; }
#tileDemoBegin:active { opacity: .6; transform: scale(.98); }
@keyframes tileTourFinaleText { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 150ms;
  }

  .tile-demo::after { transition: opacity 150ms ease; }
  #tileDemoBegin { animation-duration: 150ms; animation-delay: 0ms; }
  #tileDemoBegin small { animation-duration: 150ms; animation-delay: 0ms; }
  #tileDemoBegin:active { transform: none; }
  .tile-demo .tile-demo-text-button:active,
  .tile-demo .tile-demo-next:active { transform: none; }
}
@media (max-width: 480px) {
  .tile-demo .tile-demo-shell { left: 20px; right: 20px; width: auto; bottom: max(20px, env(safe-area-inset-bottom)); }
}

/* Native management dialogs share the existing settings/editor material. */
.tile-management-dialog {
  box-sizing: border-box;
  width: min(92vw, 548px);
  max-height: min(86dvh, 760px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 22px;
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: 0 28px 72px rgba(0,0,0,.36), inset 0 1px 0 rgba(255,255,255,.05);
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.light-mode .tile-management-dialog {
  box-shadow: 0 28px 72px rgba(15,23,42,.16), inset 0 1px 0 rgba(255,255,255,.72);
}
.tile-management-dialog::backdrop {
  background: rgba(0,0,0,.34);
  backdrop-filter: blur(12px) saturate(1.08);
  -webkit-backdrop-filter: blur(12px) saturate(1.08);
}
body.light-mode .tile-management-dialog::backdrop { background: rgba(17,24,39,.18); }
.tile-management-dialog .setup-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin: 0; }
.tile-management-dialog .setup-header h2 { margin: 0; font-size: 1.2rem; font-weight: 600; line-height: 1.3; letter-spacing: -.02em; }
.tile-management-dialog .dialog-close { min-height: 34px; }
.tile-management-dialog .after-school-description { margin: 12px 0 16px; font-size: .875rem; line-height: 1.55; }
.tile-management-dialog input,
.tile-management-dialog textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
  font: inherit;
  font-size: 1rem;
}
.tile-management-dialog input[type="radio"] { width: auto; min-height: 0; padding: 0; }
.tile-management-dialog input:focus-visible,
.tile-management-dialog textarea:focus-visible { outline: 2px solid var(--text-soft); outline-offset: 2px; }
.tile-management-dialog .after-school-list { max-height: none; overflow: visible; margin: 16px 0; }
.tile-management-dialog .form-message:empty { display: none; }
.tile-management-dialog[open] { opacity: 1; }
.management-studio-grid { display: grid; gap: 10px; margin-top: 18px; }
.management-studio-action {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 76px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, transform 120ms ease;
}
.management-studio-action span { font-size: .95rem; font-weight: 600; letter-spacing: -.015em; }
.management-studio-action small { color: var(--text-soft); font-size: .76rem; font-weight: 500; line-height: 1.45; }
.management-studio-action:hover { border-color: rgba(255,255,255,.18); background: var(--toggle-bg); }
body.light-mode .management-studio-action:hover { border-color: rgba(17,24,39,.15); }
.management-studio-action:active { transform: scale(.985); }
.management-studio-action:focus-visible { outline: 2px solid var(--text-soft); outline-offset: 3px; }
#timetable.is-management-target { box-shadow: 0 0 0 3px var(--focus-glow-soft), 0 0 36px var(--focus-glow-soft); }

/* Timetable actions read as one intentional control surface, not loose text. */
.timetable-actions {
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-soft) 82%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.timetable-actions-primary,
.timetable-actions-secondary {
  gap: 6px;
}

.timetable-actions .secondary-action {
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 120ms ease;
}

.timetable-actions .secondary-action:hover {
  border-color: color-mix(in srgb, var(--text-soft) 40%, var(--border));
  background: var(--toggle-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 7px 18px rgba(0, 0, 0, 0.12);
}

.timetable-actions .timetable-edit-action {
  border-color: transparent;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.timetable-actions .timetable-edit-action:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--text) 90%, var(--bg));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.timetable-menu-action span {
  display: inline-block;
  margin-left: 4px;
  color: var(--text-soft);
  font-size: 0.78em;
  transform: translateY(-1px);
}

@media (max-width: 480px) {
  .tile-management-dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 32px); padding: 20px; }
}

@media (max-width: 600px) {
  .timetable-actions-primary,
  .timetable-actions-secondary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timetable-actions-secondary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .timetable-actions .secondary-action {
    width: 100%;
    padding-inline: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile-management-dialog button { transition: opacity 150ms ease; }
  .tile-management-dialog button:active { transform: none; opacity: .7; }
  .management-studio-action { transition: opacity 150ms ease; }
  #timetable.is-management-target { box-shadow: 0 0 0 2px var(--focus-glow-soft); }
}

/* Both status surfaces share the same reading order. */
#neisStatus { font-weight: 500; font-variation-settings: "wght" 500; }
.floating-topbar .status-card {
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.34fr) minmax(0, 1.18fr) minmax(0, 1.16fr) minmax(0, 1fr);
  gap: 16px;
}
html[data-status-layout="focused"] .floating-topbar .status-item-period { order: 1; }
html[data-status-layout="focused"] .floating-topbar .status-item-room { order: 2; }
html[data-status-layout="focused"] .floating-topbar .status-item-remaining { order: 3; }
html[data-status-layout="focused"] .floating-topbar .status-item-time { order: 4; }
html[data-status-layout="focused"] .floating-topbar .status-item-day { order: 5; }

@media (max-width: 980px) {
  .floating-topbar .status-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .hero { gap: 14px; }
  .hero-copy { width: 100%; min-width: 0; }
  .school-meta-line { align-items: flex-start; gap: 7px; }
  .school-meta-line .subtitle { width: 100%; line-height: 1.45; }
  .controls {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) auto;
    align-items: start;
    gap: 8px;
  }
  .controls > .theme-toggle, .controls > .tool-menu { min-width: 0; }
  .controls .theme-toggle { min-height: 42px; padding-inline: 10px; font-size: .82rem; }
  .controls .tool-menu { width: auto; }
  .controls .tile-version-label { right: 0; }
  .tool-menu-panel { left: auto; right: 0; width: min(280px, calc(100vw - 36px)); }
}

@media (max-width: 600px) {
  .timetable-actions-primary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timetable-actions-primary .secondary-action { padding-inline: 5px; font-size: .73rem; white-space: nowrap; }
}

/* After-school editing uses the same quiet, tactile controls as timetable management. */
.after-school-dialog .after-school-item {
  min-height: 68px;
  padding: 11px 12px 11px 16px;
  border-radius: 15px;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--border), inset 0 1px 0 rgba(255, 255, 255, .035);
}
.after-school-dialog .after-school-item + .after-school-item { margin-top: 8px; }
.after-school-item-copy { display: grid; min-width: 0; gap: 3px; }
.after-school-item-copy strong { font-size: .9rem; line-height: 1.25; letter-spacing: -.01em; }
.after-school-item-copy span {
  color: var(--text-soft);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}
.after-school-dialog .after-school-remove {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text-soft);
  white-space: nowrap;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, transform 120ms ease;
}
.after-school-dialog .after-school-remove:hover { background: var(--toggle-bg); color: var(--text); }
.after-school-dialog .after-school-remove.is-confirming { border-color: rgba(255, 100, 100, .4); color: #ff9b98; }
body.light-mode .after-school-dialog .after-school-remove.is-confirming { color: #b4232d; }
.after-school-dialog #afterSchoolAdd {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 180ms ease, box-shadow 180ms ease, transform 120ms ease, opacity 180ms ease;
}
.after-school-dialog #afterSchoolAdd:hover:not(:disabled) {
  background: color-mix(in srgb, var(--text) 90%, var(--bg));
  box-shadow: 0 7px 18px rgba(0, 0, 0, .16), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.after-school-dialog #afterSchoolAdd:active:not(:disabled) { transform: translateY(1px) scale(.985); }
@media (prefers-reduced-motion: reduce) {
  .after-school-dialog #afterSchoolAdd,
  .after-school-dialog .after-school-remove { transition: opacity 150ms ease; }
  .after-school-dialog #afterSchoolAdd:active:not(:disabled) { transform: none; opacity: .72; }
}
