:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --text: #182126;
  --muted: #65727a;
  --line: #d9e1e5;
  --primary: #136f63;
  --primary-strong: #0b4c45;
  --danger: #b42600;
  --break: #0d663f;
  --after: #274f8f;
  --idle: #66727a;
  --shadow: 0 14px 38px rgba(25, 43, 54, 0.14);
  --app-viewport-height: 100dvh;
  --bottom-ad-height: calc(52px + env(safe-area-inset-bottom));
  --bottom-shell-height: calc(64px + var(--bottom-ad-height));
  --bottom-ad-content-safe-bottom: env(safe-area-inset-bottom);
  --landscape-ad-gap: 0px;
  --mobile-main-height: calc(100dvh - var(--bottom-shell-height));
  --mobile-clock-max: 40dvh;
  --mobile-time-size: 2.4rem;
  --mobile-countdown-size: 1.7rem;
  font-family:
    "Noto Sans JP",
    "Source Han Sans JP",
    "Noto Sans CJK JP",
    "源ノ角ゴシック",
    "Hiragino Sans",
    "Yu Gothic",
    sans-serif;
}

:root.dark {
  color-scheme: dark;
  --bg: #151a1d;
  --surface: #20272b;
  --surface-2: #2a3439;
  --text: #eef4f5;
  --muted: #a9b5ba;
  --line: #3b474d;
  --primary: #4ab8a9;
  --primary-strong: #70d8ca;
  --danger: #ff7a59;
  --break: #35a66f;
  --after: #79a8ef;
  --idle: #9aa8ae;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.startup-splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  gap: 10px;
  background: #ffffff;
  color: #111111;
  text-align: center;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.startup-splash.hide {
  visibility: hidden;
  opacity: 0;
}

.startup-splash-title {
  font-size: clamp(1.82rem, 9.1vmin, 3.78rem);
  font-weight: 700;
  line-height: 1.05;
}

.startup-splash-subtitle {
  font-size: clamp(1.3rem, 6vmin, 2.4rem);
  font-weight: 500;
  line-height: 1.1;
}

.startup-splash-version {
  margin-top: 8px;
  font-size: clamp(0.78rem, 2.5vmin, 1rem);
  font-weight: 600;
  letter-spacing: 0;
  opacity: 0.62;
}

.startup-splash-error {
  padding: 24px;
}

.startup-splash-error-detail {
  max-width: min(320px, calc(100vw - 48px));
  color: #4c555c;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.55;
}

.startup-reload-button {
  min-height: 44px;
  margin-top: 8px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  background: #136f63;
  color: white;
  font-weight: 700;
}

#app-shell {
  min-height: var(--app-viewport-height);
  display: grid;
  grid-template-rows: 1fr auto;
}

#app {
  outline: none;
  min-width: 0;
}

.screen {
  width: min(1120px, 100%);
  min-height: calc(var(--app-viewport-height) - 74px);
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px 92px;
}

.main-screen {
  display: grid;
  grid-template-rows: auto auto minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: stretch;
  /* position: relative; */
  overflow: hidden;
}

.main-screen.has-background::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--main-bg-image);
  background-size: var(--main-bg-size, cover);
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--main-bg-opacity, 0.35);
  z-index: 0;
}

.main-screen > * {
  position: relative;
  z-index: 1;
}

.status-band,
.next-band,
.digital-band,
.edit-panel,
.io-panel,
.timer-display,
.timer-controls,
.settings-list,
.appearance-panel,
.background-panel,
.interrupt-panel,
.help-panel,
.settings-actions {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.status-band,
.next-band {
  color: white;
  padding: 14px 18px;
  border: 0;
  text-align: center;
}

.status-band {
  border-radius: 999px;
}

.timetable-table-trigger {
  cursor: pointer;
  touch-action: manipulation;
}

.timetable-table-trigger:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.8);
  outline-offset: 3px;
}

.status-text-stack {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 0;
  padding-inline: 30px;
}

.status-table-icon {
  position: absolute;
  right: 18px;
  top: 50%;
  width: 24px;
  height: 24px;
  color: currentColor;
  opacity: 0.86;
  transform: translateY(-50%);
  pointer-events: none;
}

.next-band {
  border-radius: 20px;
  display: grid;
  align-items: center;
  justify-content: center;
  justify-items: center;
  gap: 12px;
}

.status-band.inClass {
  background: var(--status-in-class-bg, var(--danger));
}

.status-band.breakTime {
  background: var(--status-break-bg, var(--break));
}

.status-band.afterSchool {
  background: var(--status-after-bg, var(--after));
}

.status-band.noTimetable {
  background: var(--status-idle-bg, var(--idle));
}

.next-band {
  background: var(--next-card-bg, var(--break));
}

.status-label {
  font-size: clamp(1.3rem, 5vw, 2.4rem);
  font-weight: 500;
  line-height: 1.08;
}

.status-detail,
.next-meta {
  font-size: 0.95rem;
  opacity: 0.88;
}

.status-timetable-name {
  font-size: clamp(0.98rem, 3.2vw, 1.25rem);
  font-weight: 500;
  opacity: 0.92;
}

.next-meta {
  font-size: clamp(1.18rem, 4.4vw, 1.55rem);
}

.schedule-warning {
  max-width: min(100%, 440px);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.22);
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
}

.countdown {
  font-size: clamp(1.7rem, 8.6vw, 3.35rem);
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  font-family: Arial, sans-serif;
}

.today-schedule-list {
  display: none;
}

.today-period-row,
.today-period-empty {
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.16);
  color: white;
}

.today-period-row {
  display: grid;
  grid-template-columns: minmax(52px, auto) 1fr;
  gap: 10px;
  align-items: center;
}

.today-period-row.active {
  background: #00f5ff;
  color: #062226;
}

.today-period-number {
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-period-time {
  font-family: Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.today-break-marker {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 16px;
  padding: 0 10px;
  opacity: 0.72;
}

.today-break-dot {
  width: 7px;
  height: 7px;
  justify-self: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.68);
}

.today-break-line {
  height: 1px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.32);
}

.today-break-marker.active {
  min-height: 16px;
  opacity: 1;
}

.today-break-marker.active .today-break-dot {
  width: 0;
  height: 0;
  border-radius: 0;
  background: transparent;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #00f5ff;
}

.today-break-marker.active .today-break-line {
  height: 1px;
  background: rgba(0, 245, 255, 0.56);
}

.clock-panel {
  min-height: 280px;
  display: grid;
  place-items: center;
  position: relative;
}

.analog-clock {
  width: min(78dvw, 430px);
  aspect-ratio: 1;
  display: block;
  opacity: var(--clock-opacity, 1);
  filter: drop-shadow(0 16px 28px rgba(24, 33, 38, 0.15));
}

.asset-clock {
  position: relative;
}

.clock-panel-asset {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.clock-hand-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.clock-hand-line,
.clock-hand-shadow,
.clock-hand-tip-highlight,
.clock-second-dot,
.clock-pin-dot {
  pointer-events: none;
}

.clock-schedule-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  padding: 18px 16px;
  border-radius: 20px;
  overflow: hidden;
  color: white;
  background: var(--clock-schedule-overlay-bg, rgba(5, 26, 28, 0.82));
  backdrop-filter: blur(2px);
  pointer-events: none;
}

.clock-schedule-title {
  text-align: center;
  font-size: 0.92rem;
  font-weight: 500;
  opacity: 0.9;
}

.clock-schedule-overlay .today-schedule-list {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding: 0 4px 6px;
  scrollbar-width: thin;
}

.clock-schedule-overlay .today-period-row,
.clock-schedule-overlay .today-period-empty {
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.14);
}

.clock-schedule-overlay .today-period-row {
  grid-template-columns: minmax(44px, auto) 1fr;
  gap: 8px;
}

.clock-schedule-overlay .today-period-row.active {
  background: #00f5ff;
  color: #062226;
}

.clock-schedule-overlay .today-period-time {
  font-size: 0.88rem;
}

.weekly-timetable-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  padding: calc(14px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: var(--weekly-overlay-bg, rgba(5, 11, 14, 0.58));
  backdrop-filter: none;
}

.weekly-timetable-panel {
  width: min(980px, 100%);
  height: min(720px, 100%);
  align-self: center;
  justify-self: center;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: var(--weekly-panel-opacity, 1);
  backdrop-filter: none;
}

.weekly-timetable-header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.weekly-timetable-heading {
  min-width: 0;
}

.weekly-timetable-title {
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.3;
}

.weekly-timetable-subtitle {
  max-width: min(70vw, 760px);
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weekly-timetable-scroll {
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.weekly-timetable-table {
  width: 100%;
  min-width: 760px;
  table-layout: fixed;
  border-spacing: 0;
  border-collapse: separate;
  font-size: 0.84rem;
}

.weekly-timetable-table th,
.weekly-timetable-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.weekly-timetable-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 6px;
  background: var(--surface-2);
  color: var(--text);
  text-align: center;
  font-weight: 800;
}

.weekly-timetable-table tr > :first-child {
  border-left: 1px solid var(--line);
}

.weekly-timetable-table thead tr:first-child > * {
  border-top: 1px solid var(--line);
}

.weekly-timetable-table th.today-column {
  color: var(--primary-strong);
}

.weekly-period-heading {
  width: 54px;
  min-width: 54px;
  background: var(--surface-2);
  text-align: center;
  vertical-align: middle;
  font-weight: 800;
}

.weekly-timetable-table tbody .weekly-period-heading {
  padding: 6px 4px;
}

.weekly-timetable-cell {
  height: 92px;
  padding: 6px;
  vertical-align: top;
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-2));
}

.weekly-cell-stack {
  display: grid;
  gap: 5px;
}

.weekly-period-item {
  min-height: 56px;
  display: grid;
  align-content: start;
  gap: 2px;
  border-radius: 8px;
  padding: 6px 7px;
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  color: var(--text);
}

.weekly-period-item.active {
  background: #00f5ff;
  color: #062226;
}

.weekly-period-item.overlap {
  box-shadow: inset 0 0 0 2px var(--danger);
}

.weekly-period-subject {
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.24;
  overflow-wrap: anywhere;
}

.weekly-period-time,
.weekly-period-source {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weekly-period-time {
  font-family: Arial, sans-serif;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.84;
}

.weekly-period-source {
  color: var(--muted);
  font-size: 0.72rem;
}

.weekly-period-item.active .weekly-period-source {
  color: rgba(6, 34, 38, 0.78);
}

.weekly-empty-cell {
  min-height: 56px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.weekly-timetable-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.mini-clock-overlay {
  position: fixed;
  inset: 0;
  padding: 16px 16px calc(88px + env(safe-area-inset-bottom));
  display: grid;
  align-items: end;
  justify-items: end;
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(2px);
  z-index: 30;
}

:root.show-ad-slot .mini-clock-overlay {
  padding-bottom: calc(144px + env(safe-area-inset-bottom));
}

.mini-clock-card {
  width: min(340px, calc(100dvw - 24px));
  border: 1px solid color-mix(in srgb, var(--line) 68%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  padding: 10px;
}

.mini-clock-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
}

.mini-clock-status {
  font-weight: 800;
  font-size: 1rem;
}

.mini-clock-detail {
  color: var(--muted);
  font-size: 0.82rem;
}

.mini-close-button {
  flex: 0 0 38px;
}

.mini-clock-panel {
  min-height: 150px;
}

.mini-clock-panel .analog-clock {
  width: min(44dvw, 170px);
}

.mini-clock-time {
  text-align: center;
  font-size: 1.9rem;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.digital-band {
  background: var(--digital-card-bg, var(--surface));
  color: var(--digital-text, var(--text));
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  text-align: center;
}

.date-text {
  color: var(--digital-subtext, var(--muted));
  font-size: clamp(0.92rem, 3vw, 1.1rem);
}

.time-text {
  font-size: clamp(2rem, 12vw, 4rem);
  line-height: 1;
  font-weight: 500;
  font-family: Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

.clock-panel {
  font-family: Arial, sans-serif;
}

.bottom-ad-slot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--bottom-ad-height);
  padding: 4px 10px calc(4px + var(--bottom-ad-content-safe-bottom));
  display: none;
  place-items: center;
  overflow: hidden;
  background: #ffffff;
  border-top: 0;
  color: #2b332c;
  font-size: 0.88rem;
  font-weight: 800;
  z-index: 12;
}

.bottom-ad-slot img {
  display: block;
  width: auto;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
  object-position: center;
}

:root.show-ad-slot .bottom-ad-slot {
  display: grid;
}

:root.show-ad-slot .bottom-nav {
  bottom: var(--bottom-ad-height);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 64px;
  padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  background: #000000;
  border-top: 0;
  z-index: 10;
}

.nav-button,
.action-button,
.icon-text-button,
.day-tab,
.icon-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  min-height: 42px;
}

.nav-button {
  border-radius: 8px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #00f020;
}

.action-button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.nav-button.active {
  background: transparent;
  color: #00f020;
}

.nav-button.nav-toggle {
  color: #8a8a8a;
}

.nav-button.nav-toggle.toggle-on {
  color: #00f5ff;
}

.nav-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  background: currentColor;
  -webkit-mask: var(--nav-icon) center / contain no-repeat;
  mask: var(--nav-icon) center / contain no-repeat;
}

.nav-icon-main {
  --nav-icon: url("./icons/android/home.svg");
}

.nav-icon-timetable {
  --nav-icon: url("./icons/android/content_paste.svg");
}

.nav-icon-timer {
  --nav-icon: url("./icons/android/timer.svg");
}

.nav-icon-settings {
  --nav-icon: url("./icons/android/settings.svg");
}

.nav-icon-rotate {
  --nav-icon: url("./icons/android/refresh.svg");
}

.nav-icon-alarm {
  --nav-icon: url("./icons/android/notifications.svg");
}

.nav-icon-lock {
  --nav-icon: url("./icons/android/lock.svg");
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-button.danger,
.icon-button.danger {
  border-color: color-mix(in srgb, var(--danger) 62%, var(--line));
  color: var(--danger);
}

.toolbar,
.button-row,
.preset-grid,
.interrupt-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.settings-screen .settings-actions,
.settings-screen .button-row,
.settings-screen .interrupt-form,
.timetable-screen .toolbar,
.timetable-screen .button-row,
.timetable-screen .day-tabs,
.timetable-screen .copy-controls,
.timer-screen .button-row,
.timer-screen .preset-grid {
  gap: 14px;
}

:is(.settings-screen, .timetable-screen, .timer-screen) .action-button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--surface-2) 86%, var(--surface));
  color: var(--text);
  box-shadow:
    0 2px 3px rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.18);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background-color 0.12s ease;
}

:is(.settings-screen, .timetable-screen, .timer-screen) .action-button.primary {
  background: var(--primary);
  color: white;
  box-shadow:
    0 3px 6px color-mix(in srgb, var(--primary) 34%, transparent),
    0 1px 2px rgba(0, 0, 0, 0.18);
}

:is(.settings-screen, .timetable-screen, .timer-screen) .action-button.danger {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  color: var(--danger);
}

:is(.settings-screen, .timetable-screen, .timer-screen) .action-button:active,
:is(.settings-screen, .timetable-screen, .timer-screen) .icon-button:active,
.timetable-screen .day-tab:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

:is(.settings-screen, .timetable-screen, .timer-screen) .icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface-2) 86%, var(--surface));
  color: var(--text);
  box-shadow:
    0 2px 3px rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.18);
}

:is(.settings-screen, .timetable-screen, .timer-screen) .icon-button.danger {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  color: var(--danger);
}

.toolbar {
  margin-bottom: 12px;
}

.field-select,
.text-input,
.time-input,
.number-input,
.timer-input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
}

.field-select {
  flex: 1;
  min-width: 210px;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.field > input,
.field > select {
  width: 100%;
  min-width: 0;
  color: var(--text);
}

.edit-panel,
.io-panel,
.timer-display,
.timer-controls,
.settings-list,
.appearance-panel,
.background-panel,
.interrupt-panel,
.help-panel,
.settings-actions {
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.day-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 0;
}

.day-tab {
  border-radius: 8px;
  min-height: 38px;
  min-width: 0;
  padding: 0 4px;
}

.day-tab.active {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  color: white;
}

.timetable-screen .day-tab {
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-2) 86%, var(--surface));
  color: var(--text);
  box-shadow:
    0 2px 3px rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.18);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background-color 0.12s ease;
}

.timetable-screen .day-tab.active {
  background: var(--primary-strong);
  color: white;
  box-shadow:
    0 3px 6px color-mix(in srgb, var(--primary-strong) 34%, transparent),
    0 1px 2px rgba(0, 0, 0, 0.18);
}

.timetable-screen .day-tabs {
  gap: 6px;
}

.assignment-panel {
  display: grid;
  gap: 10px;
  margin: 12px 0 14px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
}

.assignment-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
  justify-content: space-between;
}

.assignment-title {
  color: var(--text);
  font-weight: 700;
}

.assignment-help {
  color: var(--muted);
  font-size: 0.78rem;
}

.weekday-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.weekday-checkbox {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.weekday-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.assignment-warning {
  border-radius: 8px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.45;
}

.period-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.copy-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  margin: 0 0 12px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 8px;
}

.period-row {
  display: grid;
  grid-template-columns: minmax(56px, 0.6fr) minmax(106px, 0.95fr) minmax(106px, 0.95fr) minmax(150px, 1.4fr) 44px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 8px;
}

.period-subject-field {
  min-width: 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-weight: 900;
  line-height: 1;
}

.hidden {
  display: none !important;
}

.timer-screen {
  display: grid;
  gap: 12px;
  align-content: start;
}

.timer-display {
  display: grid;
  justify-items: center;
  gap: 18px;
}

.timer-ring {
  --progress: 0deg;
  width: min(72dvw, 280px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--primary) var(--progress), var(--surface-2) 0);
  display: grid;
  place-items: center;
}

.timer-ring-fill {
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  font-size: clamp(1.4rem, 8vw, 2.6rem);
  font-weight: 800;
  text-align: center;
}

.timer-progress {
  width: min(460px, 100%);
  height: 14px;
  accent-color: var(--primary);
}

.timer-controls {
  display: grid;
  gap: 18px;
}

.timer-controls .field {
  gap: 8px;
  font-size: 0.88rem;
}

.timer-controls .preset-grid,
.timer-controls .button-row {
  gap: 12px;
}

.timer-input {
  min-height: 48px;
  font-size: 1.06rem;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.settings-list {
  display: grid;
  padding: 0;
  overflow: hidden;
}

.appearance-panel h2,
.background-panel h2,
.interrupt-panel h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.appearance-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.color-input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: var(--surface);
}

.background-preview {
  min-height: 130px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface-2);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  margin-bottom: 12px;
  overflow: hidden;
}

.background-preview.has-image {
  border-style: solid;
}

.background-controls {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.range-input {
  width: 100%;
  accent-color: var(--primary);
}

.field-select.compact {
  min-width: 0;
  width: 100%;
}

.toggle-row,
.select-row,
.custom-sound-row,
.notification-row {
  min-height: 58px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.toggle-row:last-child,
.select-row:last-child,
.custom-sound-row:last-child,
.notification-row:last-child {
  border-bottom: 0;
}

.select-row {
  gap: 12px;
}

.select-row > span {
  min-width: 0;
}

.select-row > select {
  max-width: 210px;
}

.custom-sound-row {
  gap: 12px;
}

.custom-sound-info {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.custom-sound-info small {
  max-width: min(44vw, 340px);
  color: var(--muted);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-sound-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.custom-sound-actions .action-button {
  min-height: 38px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

.sound-credit {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
  text-align: right;
}

.sound-credit a,
.help-panel a {
  color: var(--primary-strong);
  text-decoration: none;
}

.sound-credit a:hover,
.help-panel a:hover {
  text-decoration: underline;
}

.toggle-row input {
  width: 48px;
  height: 28px;
  accent-color: var(--primary);
}

.interrupt-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  align-items: end;
}

.help-screen {
  display: grid;
  align-content: start;
}

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

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

.help-header h1 {
  margin: 0 0 4px;
  font-size: 1.35rem;
}

.help-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.help-section {
  display: grid;
  gap: 6px;
}

.help-section h2 {
  margin: 0;
  font-size: 1rem;
}

.help-section ul {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text);
  line-height: 1.65;
}

.help-section li::marker {
  color: var(--primary);
}

.help-sound-credit {
  padding: 10px 0 0;
  border-bottom: 0;
  border-top: 1px solid var(--line);
}

.interrupt-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.interrupt-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 8px;
}

.interrupt-item span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  background: var(--primary-strong);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.toast.error {
  background: var(--danger);
}

@media (min-width: 820px) {
  .main-screen {
    grid-template-columns: 1fr 1.05fr;
    grid-template-rows: auto 1fr auto;
  }

  .next-band {
    grid-template-rows: auto auto minmax(0, 1fr);
    align-content: stretch;
    justify-content: stretch;
    min-height: 0;
  }

  .next-band > .today-schedule-list {
    width: 100%;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    display: grid;
    align-content: start;
    gap: 8px;
    padding: 2px 2px 0;
    scrollbar-width: thin;
  }

  .clock-schedule-overlay {
    display: none !important;
  }

  .status-band,
  .next-band,
  .digital-band {
    grid-column: 1;
  }

  .clock-panel {
    grid-column: 2;
    grid-row: 1 / 5;
  }

  .bottom-nav {
    width: min(900px, calc(100% - 32px));
    left: 50%;
    transform: translateX(-50%);
    border: 0;
    border-radius: 16px 16px 0 0;
  }
}

@media (max-width: 819px) {
  .schedule-toggle-clock {
    cursor: pointer;
  }

  .main-screen.today-schedule-open .clock-schedule-overlay {
    display: grid;
  }
}

@media (max-width: 640px) {
  .screen {
    padding: calc(12px + env(safe-area-inset-top)) 10px 90px;
  }

  .main-screen {
    --mobile-shell-bottom: var(--bottom-shell-height);
    width: 100%;
    height: var(--mobile-main-height);
    min-height: 0;
    padding: calc(10px + env(safe-area-inset-top)) 8px 8px;
    grid-template-rows:
      max-content
      max-content
      minmax(0, 1fr)
      max-content;
    gap: clamp(5px, 0.9dvh, 8px);
    overflow: hidden;
  }

  .main-screen .status-band,
  .main-screen .next-band {
    padding: clamp(8px, 1.4dvh, 12px) 12px;
    min-height: max-content;
    overflow: visible;
  }

  .main-screen .status-label {
    font-size: clamp(1.15rem, 4.8dvw, 1.8rem);
  }

  .main-screen .status-timetable-name {
    font-size: clamp(0.82rem, 3dvw, 1rem);
  }

  .main-screen .next-band {
    padding-block: clamp(14px, 2.32dvh, 20px);
    gap: clamp(4px, 0.9dvh, 8px);
  }

  .main-screen .next-meta {
    font-size: clamp(0.82rem, 3.4dvw, 1.08rem);
  }

  .main-screen .countdown {
    font-size: var(--mobile-countdown-size);
    line-height: 1;
  }

  .main-screen .clock-panel {
    min-height: 0;
    align-self: stretch;
    place-items: center;
    overflow: hidden;
    padding-block: 0;
  }

  .analog-clock {
    width: min(88dvw, 100%, var(--mobile-clock-max));
  }

  .main-screen .digital-band {
    align-self: end;
    min-height: max-content;
    padding: clamp(7px, 1.1dvh, 11px) 14px;
    overflow: visible;
  }

  .main-screen .date-text {
    font-size: clamp(0.72rem, 2.7dvw, 0.94rem);
    line-height: 1.2;
  }

  .main-screen .time-text {
    font-size: var(--mobile-time-size);
  }

  .nav-button {
    gap: 0;
  }

  .nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .period-row {
    grid-template-columns: 68px 1fr 1fr 44px;
  }

  .period-subject-field {
    grid-column: 1 / -1;
  }

  .period-row .icon-button {
    grid-column: 4;
    grid-row: 1;
  }

  .weekly-timetable-overlay {
    padding: calc(8px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .weekly-timetable-panel {
    height: 100%;
    border-radius: 12px;
  }

  .weekly-timetable-header {
    padding: 10px;
  }

  .weekly-timetable-subtitle {
    max-width: 64vw;
  }

  .weekly-timetable-scroll {
    padding: 8px;
  }

  .weekly-timetable-table {
    min-width: 680px;
    font-size: 0.78rem;
  }

  .weekly-timetable-cell {
    height: 76px;
    padding: 5px;
  }

  .weekly-period-item {
    min-height: 48px;
    padding: 5px 6px;
  }

  .preset-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .interrupt-form {
    grid-template-columns: 1fr 1fr;
  }

  .background-controls {
    grid-template-columns: 1fr;
  }

  .appearance-controls {
    grid-template-columns: 1fr;
  }

  .interrupt-form .action-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 390px) {
  .main-screen {
    grid-template-rows:
      max-content
      max-content
      minmax(0, 1fr)
      max-content;
  }

  .main-screen .analog-clock {
    width: min(90dvw, 100%, var(--mobile-clock-max));
  }

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

  .period-subject-field {
    grid-column: 1 / -1;
  }

  .period-row .icon-button {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
  }
}

@media (max-width: 430px) {
  .help-header {
    align-items: stretch;
    flex-direction: column;
  }

  .help-header .action-button {
    width: 100%;
  }

  .sound-credit {
    text-align: left;
  }

  .custom-sound-row {
    align-items: stretch;
    flex-direction: column;
    padding-block: 10px;
  }

  .custom-sound-actions {
    justify-content: stretch;
  }

  .custom-sound-actions .action-button {
    flex: 1 1 130px;
  }

  .timetable-screen .day-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .day-tab {
    min-height: 40px;
  }

  .weekday-checkbox-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }
}

:root.show-ad-slot .screen {
  padding-bottom: calc(144px + env(safe-area-inset-bottom));
}

@media (max-width: 640px) {
  :root.show-ad-slot .screen {
    padding: calc(12px + env(safe-area-inset-top)) 10px calc(142px + env(safe-area-inset-bottom));
  }

  :root.show-ad-slot .main-screen {
    padding: calc(10px + env(safe-area-inset-top)) 8px 8px;
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 640px) {
  :root {
    --landscape-nav-width: calc(72px + env(safe-area-inset-right));
    --landscape-viewport-height: 100svh;
    --landscape-main-height: calc(var(--landscape-viewport-height) - var(--bottom-ad-height));
    --landscape-edge-card-height: clamp(79px, 22svh, 99px);
    --landscape-next-card-height: clamp(112px, 35svh, 170px);
    --landscape-row-gap: clamp(8px, 2.6svh, 12px);
    --bottom-ad-content-safe-bottom: max(env(safe-area-inset-bottom), 12px);
  }

  html,
  body,
  #app-shell {
    background: #f7f8f2;
  }

  #app-shell {
    height: var(--landscape-viewport-height);
    min-height: 0;
    grid-template-rows: 1fr;
    overflow: auto;
  }

  .screen {
    width: calc(100% - var(--landscape-nav-width));
    min-height: var(--landscape-main-height);
    margin: 0;
    padding: clamp(8px, 2svh, 14px) 12px calc(var(--bottom-ad-height) + 12px);
  }

  .main-screen {
    padding: clamp(8px, 2svh, 14px) 12px clamp(5px, 1.2svh, 8px);
  }

  .main-screen {
    width: calc(100% - var(--landscape-nav-width));
    height: var(--landscape-main-height);
    max-height: var(--landscape-main-height);
    min-height: 0;
    padding: clamp(8px, 2svh, 14px) 12px clamp(5px, 1.2svh, 8px);
    display: grid;
    grid-template-columns: minmax(180px, 0.92fr) minmax(300px, 1fr);
    grid-template-rows:
      var(--landscape-edge-card-height)
      var(--landscape-next-card-height)
      var(--landscape-edge-card-height);
    column-gap: clamp(12px, 2.2dvw, 24px);
    row-gap: var(--landscape-row-gap);
    align-content: start;
    align-items: stretch;
    overflow: hidden;
  }

  .main-screen .clock-panel {
    grid-column: 1;
    grid-row: 1 / 4;
    min-height: 0;
    align-self: stretch;
    place-items: center;
    overflow: visible;
  }

  .main-screen .analog-clock {
    width: min(100%, var(--mobile-clock-max));
  }

  .main-screen .status-band,
  .main-screen .next-band,
  .main-screen .digital-band {
    grid-column: 2;
    width: 100%;
  }

  .main-screen .status-band {
    grid-row: 1;
    min-height: var(--landscape-edge-card-height);
    padding: clamp(8px, 2svh, 14px) 16px;
    display: grid;
    align-content: center;
  }

  .main-screen .status-timetable-name {
    font-size: 1em;
  }

  .main-screen .status-label {
    font-size: clamp(1.45rem, 4.4svh, 2.35rem);
    font-weight: 700;
  }

  .main-screen .next-band {
    grid-row: 2;
    align-self: center;
    height: 100%;
    min-height: 0;
    padding: clamp(10px, 2.4svh, 18px) 18px;
    gap: clamp(6px, 1.8svh, 12px);
  }

  .main-screen .next-meta {
    font-size: 1em;
  }

  .main-screen .countdown {
    font-size: clamp(2.2rem, 8.8svh, 4.51rem);
    line-height: 1;
  }

  .main-screen .digital-band {
    grid-row: 3;
    align-self: end;
    min-height: var(--landscape-edge-card-height);
    padding: clamp(8px, 1.8svh, 14px) 16px;
    display: grid;
    align-content: center;
  }

  .main-screen .date-text {
    font-size: 1em;
  }

  .main-screen .time-text {
    font-size: clamp(2rem, 7svh, 3.3rem);
  }

  .clock-schedule-overlay {
    inset: 0;
  }

  .main-screen.today-schedule-open .clock-schedule-overlay {
    display: grid;
  }

  .bottom-nav {
    left: auto;
    right: 0;
    bottom: 0;
    width: var(--landscape-nav-width);
    height: var(--landscape-viewport-height);
    min-height: 0;
    padding: calc(34px + env(safe-area-inset-top)) calc(6px + env(safe-area-inset-right)) 12px 6px;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(6, 1fr);
    border-radius: 0;
    transform: none;
  }

  .nav-button {
    min-height: 0;
  }

  .nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  :root.show-ad-slot .bottom-nav {
    bottom: 0;
  }

  .bottom-ad-slot {
    right: var(--landscape-nav-width);
    height: var(--bottom-ad-height);
  }

  :root.show-ad-slot .screen {
    padding: clamp(8px, 2svh, 14px) 12px calc(var(--bottom-ad-height) + 16px);
  }

  :root.show-ad-slot .main-screen {
    padding: clamp(8px, 2svh, 14px) 12px clamp(5px, 1.2svh, 8px);
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 340px) {
  :root {
    --landscape-edge-card-height: clamp(46px, 16.5svh, 59px);
    --landscape-next-card-height: clamp(112px, 35svh, 170px);
    --landscape-row-gap: 8px;
  }

  .main-screen {
    grid-template-rows:
      var(--landscape-edge-card-height)
      var(--landscape-next-card-height)
      var(--landscape-edge-card-height);
    row-gap: var(--landscape-row-gap);
  }

  .main-screen .status-band {
    min-height: var(--landscape-edge-card-height);
    padding: 4px 14px;
  }

  .main-screen .status-timetable-name {
    font-size: 1em;
  }

  .main-screen .status-label {
    font-size: clamp(1rem, 4.1svh, 1.45rem);
    font-weight: 700;
  }

  .main-screen .next-band {
    padding: 4px 14px;
    gap: 2px;
  }

  .main-screen .next-meta {
    font-size: 1em;
  }

  .main-screen .countdown {
    font-size: clamp(1.21rem, 7.7svh, 1.76rem);
  }

  .main-screen .digital-band {
    min-height: var(--landscape-edge-card-height);
    padding: 3px 14px;
  }

  .main-screen .date-text {
    font-size: 1em;
    line-height: 1.1;
  }

  .main-screen .time-text {
    font-size: clamp(1.2rem, 6svh, 1.65rem);
  }

  .weekly-timetable-overlay {
    padding: 8px;
  }

  .weekly-timetable-panel {
    height: calc(100svh - 16px);
    border-radius: 12px;
  }

  .weekly-timetable-header {
    padding: 8px 10px;
  }

  .weekly-timetable-title {
    font-size: 0.98rem;
  }

  .weekly-timetable-subtitle {
    font-size: 0.74rem;
  }

  .weekly-timetable-scroll {
    padding: 8px;
  }

  .weekly-timetable-cell {
    height: 62px;
    padding: 4px;
  }

  .weekly-period-item {
    min-height: 42px;
    padding: 4px 5px;
  }

  .weekly-period-subject {
    font-size: 0.78rem;
  }

  .weekly-period-time,
  .weekly-period-source {
    font-size: 0.68rem;
  }
}
