:root {
  --page-bg: #ffffff;
  --text: #111111;
  --muted: #6f7377;
  --panel-gray: #d9d9d9;
  --panel-gray-dark: #b9bfc1;
  --line-gray: #6e6e6b;
  --soft-red: #ff787d;
  --soft-red-bg: #fde9e7;
  --soft-blue: #8188ff;
  --soft-blue-bg: #c9d8ef;
  --soft-green-bg: #dcf8c0;
  --soft-yellow-bg: #f3ffb2;
  --admin-yellow: #ffd37b;
  --admin-yellow-deep: #ffc34d;
  --changed: #c9ddc9;
  --field-bg: #fff0ee;
  --cell-gray: #e2e3e4;
  --focus: #1a73e8;
  --radius-sm: 8px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --shadow-soft: 0 12px 30px rgb(0 0 0 / 8%);
  font-family: "Yu Gothic", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page-bg);
  color: var(--text);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 4px solid color-mix(in srgb, var(--focus) 55%, white);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

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

.app-shell {
  width: min(100%, 1920px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(18px, 2.5vw, 48px);
}

.top-bar,
.admin-header,
.deep-admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}

.profile-controls,
.admin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 7px solid var(--soft-red);
  border-radius: var(--radius-md);
}

.profile-controls:has(#student-course option[value="science"]:checked) {
  border-color: var(--soft-blue);
}

.profile-controls:has(#student-course option[value="science"]:checked) .profile-chip--course {
  background: var(--soft-blue-bg);
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  min-width: 180px;
  min-height: 84px;
  gap: 8px;
  padding: 10px 22px;
  background: var(--field-bg);
  border-radius: var(--radius-md);
  color: #000;
  font-size: clamp(2rem, 2.75vw, 3.65rem);
  line-height: 1;
}

.profile-chip--class {
  background: var(--soft-green-bg);
}

.profile-chip--course {
  background: var(--field-bg);
}

.profile-chip span {
  flex: none;
}

.profile-chip select,
.profile-chip input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  line-height: 1;
  appearance: none;
}

.view-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(16px, 2.5vw, 54px);
  margin-left: auto;
}

.app-shell:not([data-view="student"]) .top-bar .profile-controls {
  display: none;
}

.view-actions [data-view-button="quick-admin"],
.view-actions [data-view-button="deep-admin"] {
  display: none;
}

.app-shell[data-view="student"] .view-actions [data-view-button="student"],
.app-shell:not([data-view="student"]) .view-actions [data-view-button="login"] {
  display: none;
}

.app-shell[data-view="quick-admin"] .view-actions [data-view-button="deep-admin"] {
  display: inline-block;
}

.app-shell[data-view="deep-admin"] .view-actions [data-view-button="quick-admin"] {
  display: inline-block;
}

.icon-button {
  width: clamp(58px, 4.4vw, 82px);
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  transition: transform 160ms ease, filter 160ms ease;
}

.icon-button:hover {
  transform: translateY(-2px);
  filter: brightness(0.96);
}

.icon-button span {
  opacity: 0;
}

.icon-button[data-view-button="student"] {
  background-image: url("アイコン目玉.png");
}

.icon-button[data-view-button="login"],
.icon-button[data-view-button="quick-admin"] {
  background-image: url("アイコンeditor.png");
}

.icon-button[data-view-button="deep-admin"] {
  background-image: url("アイコン工具.png");
}

.screen {
  width: 100%;
}

.screen--student {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(460px, 1.9fr);
  gap: clamp(24px, 2.6vw, 50px);
  align-items: stretch;
}

.timetable-panel,
.notice-panel,
.matrix-panel,
.admin-side-panel {
  border-radius: var(--radius-lg);
}

.timetable-panel {
  padding: 16px 8px 18px;
  background: var(--soft-red);
}

.panel-title {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 78px;
  margin-bottom: 20px;
}

.panel-title span {
  display: block;
  width: min(90px, 70%);
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.timetable-panel .panel-title span {
  background-image: url("アイコン時間割.png");
}

.notice-panel .panel-title span,
.admin-side-panel .panel-title span {
  background-image: url("アイコンベル.png");
}

.screen--deep-admin .admin-side-panel .panel-title span {
  background-image: url("アイコン管理者.png");
}

.panel-title h2 {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 78px;
  margin: 0;
  padding: 0 22px;
  background: var(--field-bg);
  border-radius: var(--radius-md);
  font-size: clamp(2.4rem, 3.2vw, 4.5rem);
  font-weight: 500;
  line-height: 1;
}

.period-list {
  display: grid;
  grid-template-rows: repeat(7, minmax(88px, 1fr));
  gap: 10px;
  height: calc(100% - 98px);
  min-height: 680px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.period-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--field-bg);
  border-radius: var(--radius-md);
  font-size: clamp(2.5rem, 3.2vw, 4rem);
  line-height: 1.05;
}

.period-number::before {
  content: "[";
}

.period-number::after {
  content: "]:";
}

.notice-panel {
  position: relative;
  min-height: 760px;
  padding: 6px 48px 32px;
  background: var(--panel-gray);
  overflow: hidden;
}

.notice-panel .panel-title {
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 80px;
  margin-bottom: 22px;
  padding: 0 0 0 8px;
  background: var(--panel-gray-dark);
  border-radius: var(--radius-lg);
}

.notice-panel .panel-title h2,
.admin-side-panel .panel-title h2 {
  background: transparent;
  font-size: clamp(2.35rem, 3vw, 4rem);
  position: relative; 
  text-align: center;
  place-items: center
}

.notice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  align-content: start;
  align-items: start;
  gap: clamp(22px, 3vw, 44px);
  max-height: calc(100vh - 230px);
  min-height: 570px;
  padding: 0 26px 8px 0;
  overflow: auto;
  scrollbar-width: none;
}

.notice-card,
.admin-post-card {
  min-height: 160px;
  height: auto;
  padding: 24px 28px;
  background: #fff;
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
}

.notice-card h3 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 1.65vw, 2rem);
  font-weight: 500;
  text-align: center;
}

.notice-card p {
  margin: 0;
  font-size: clamp(1.25rem, 1.55vw, 1.9rem);
  line-height: 1.45;
}

.screen--login {
  display: grid;
  min-height: 70vh;
  place-items: center;
}

.login-card {
  display: grid;
  width: min(560px, 100%);
  gap: 18px;
  padding: 34px;
  background: var(--panel-gray);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 2.6vw, 3rem);
  font-weight: 500;
}

.login-card label,
.post-form label,
.manager-form label {
  display: grid;
  gap: 8px;
}

.login-card input,
.post-form input,
.post-form textarea,
.manager-form input {
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  background: #fff;
}

.login-card button,
.post-form > button,
.manager-form button {
  min-height: 52px;
  border-radius: var(--radius-sm);
  background: #111;
  color: #fff;
  font-weight: 700;
}

.admin-header {
  justify-content: flex-start;
  width: fit-content;
  background: var(--admin-yellow-deep);
  border-color: var(--admin-yellow-deep);
}

.admin-header .profile-chip {
  min-width: 300px;
  background: var(--field-bg);
}

.admin-header .profile-chip:not(.profile-chip--grade) {
  background: #e6d9e5;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(820px, 1fr) minmax(320px, 0.24fr);
  gap: 20px;
  align-items: stretch;
}

.matrix-panel {
  padding: 34px 10px;
  background: var(--admin-yellow);
}

.screen--deep-admin .matrix-panel {
  background: var(--line-gray);
}

.timetable-matrix {
  display: grid;
  grid-template-columns: minmax(84px, 0.9fr) repeat(var(--class-count, 10), minmax(74px, 1fr));
  grid-auto-rows: minmax(92px, 1fr);
  gap: 7px;
  width: 100%;
}

.matrix-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 88px;
  padding: 8px;
  background: var(--field-bg);
  border-radius: var(--radius-md);
  color: #000;
  text-align: center;
  font-size: clamp(1.6rem, 2vw, 2.7rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

button.matrix-cell {
  transition: transform 140ms ease, filter 140ms ease;
}

button.matrix-cell:hover {
  transform: translateY(-1px);
  filter: brightness(0.96);
}

.matrix-cell--corner,
.matrix-cell--period {
  background: var(--cell-gray);
}

.subject-humanities {
  background: var(--soft-red-bg);
}

.subject-science {
  background: var(--soft-blue-bg);
}

.subject-agriculture {
  background: var(--soft-green-bg);
}

.subject-welfare {
  background: var(--soft-yellow-bg);
}

.is-changed {
  background: var(--changed);
}

.profile-controls[data-course="science"],
.profile-controls[data-course="explore-science"] {
  border-color: var(--soft-blue);
}

.profile-controls[data-course="science"] .profile-chip--course,
.profile-controls[data-course="explore-science"] .profile-chip--course,
.timetable-panel[data-course="science"],
.timetable-panel[data-course="explore-science"] {
  background: var(--soft-blue);
}

.timetable-panel[data-course="science"] .period-list li,
.timetable-panel[data-course="explore-science"] .period-list li,
.timetable-panel[data-course="science"] .panel-title h2,
.timetable-panel[data-course="explore-science"] .panel-title h2 {
  background: var(--soft-blue-bg);
}

.profile-controls[data-course="agriculture"] .profile-chip--course,
.timetable-panel[data-course="agriculture"] {
  background: #bfe88f;
}

.profile-controls[data-course="welfare"] .profile-chip--course,
.timetable-panel[data-course="welfare"] {
  background: #e8f25d;
}

.empty-state {
  padding: 22px;
  background: #fff;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 1.2rem;
}

.timetable-matrix--base .matrix-cell:not(.matrix-cell--corner):not(.matrix-cell--period):nth-child(11n + 2),
.timetable-matrix--base .matrix-cell:not(.matrix-cell--corner):not(.matrix-cell--period):nth-child(11n + 5),
.timetable-matrix--base .matrix-cell:not(.matrix-cell--corner):not(.matrix-cell--period):nth-child(11n + 6),
.timetable-matrix--base .matrix-cell:not(.matrix-cell--corner):not(.matrix-cell--period):nth-child(11n + 8) {
  background: var(--soft-red-bg);
}

.timetable-matrix--base .matrix-cell:not(.matrix-cell--corner):not(.matrix-cell--period):nth-child(11n + 3),
.timetable-matrix--base .matrix-cell:not(.matrix-cell--corner):not(.matrix-cell--period):nth-child(11n + 4),
.timetable-matrix--base .matrix-cell:not(.matrix-cell--corner):not(.matrix-cell--period):nth-child(11n + 7),
.timetable-matrix--base .matrix-cell:not(.matrix-cell--corner):not(.matrix-cell--period):nth-child(11n + 9) {
  background: var(--soft-blue-bg);
}

.timetable-matrix--base .matrix-cell:not(.matrix-cell--corner):not(.matrix-cell--period):nth-child(11n + 10) {
  background: var(--soft-green-bg);
}

.timetable-matrix--base .matrix-cell:not(.matrix-cell--corner):not(.matrix-cell--period):nth-child(11n + 11) {
  background: var(--soft-yellow-bg);
}

.timetable-matrix .matrix-cell.subject-humanities {
  background: var(--soft-red-bg);
}

.timetable-matrix .matrix-cell.subject-science {
  background: var(--soft-blue-bg);
}

.timetable-matrix .matrix-cell.subject-agriculture {
  background: var(--soft-green-bg);
}

.timetable-matrix .matrix-cell.subject-welfare {
  background: var(--soft-yellow-bg);
}

.timetable-matrix .matrix-cell.is-changed {
  background: var(--changed);
}

.admin-side-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(220px, 1fr) auto;
  gap: 14px;
  min-height: 680px;
  padding: 16px 28px 30px 12px;
  background: var(--panel-gray);
  overflow: hidden;
}

.admin-side-panel .panel-title {
  grid-template-columns: 62px minmax(0, 1fr);
  min-height: 58px;
  margin: 0;
  background: var(--panel-gray-dark);
  border-radius: var(--radius-md);
}

.admin-side-panel .panel-title span {
  width: 46px;
}

.admin-side-panel .panel-title h2 {
  min-height: 58px;
  padding: 0 8px;
  justify-content: flex-start;
  font-size: clamp(1.5rem, 1.7vw, 2.25rem);
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding-right: 22px;
}

.segmented-control button {
  min-height: 42px;
  border-radius: var(--radius-sm);
  background: #fff;
}

.segmented-control button[aria-selected="true"] {
  background: #111;
  color: #fff;
}

.admin-post-list,
.manager-list {
  display: grid;
  align-content: start;
  align-items: start;
  gap: 16px;
  max-height: 410px;
  padding: 0 22px 0 0;
  margin: 0;
  overflow: auto;
  scrollbar-width: none;
}

.admin-post-card {
  position: relative;
  min-height: 126px;
  height: max-content;
  padding: 18px;
  background: #ffd37b;
}

.admin-post-card > button,
.manager-list button {
  position: absolute;
  top: -8px;
  left: 4px;
  width: 28px;
  height: 28px;
  background: transparent;
  color: #000;
  font-size: 1.4rem;
  line-height: 1;
}

.admin-post-card p {
  margin: 0 0 14px;
  font-size: 1.03rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: normal;
}

.admin-post-card small {
  font-size: 0.98rem;
}

.post-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  margin-right: 22px;
  background: #fff;
  border-radius: var(--radius-sm);
}

.post-form textarea {
  resize: vertical;
  min-height: 112px;
}

.post-form fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0;
  padding: 10px;
  border: 2px solid var(--panel-gray);
  border-radius: var(--radius-sm);
}

.post-form legend {
  padding: 0 6px;
}

.post-form fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.target-settings {
  display: grid;
  gap: 10px;
}

.target-settings summary {
  min-height: 44px;
  padding: 11px 14px;
  background: #f3f3f3;
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow-wrap: anywhere;
}

.target-settings[open] {
  gap: 12px;
}

.deep-admin-header {
  justify-content: flex-start;
  width: fit-content;
  padding: 8px;
  background: var(--line-gray);
  border-radius: var(--radius-md);
}

.deep-admin-header .profile-chip {
  min-width: 210px;
  min-height: 84px;
}

.deep-admin-header h1 {
  min-height: 84px;
  margin: 0;
  padding: 16px 28px;
  background: var(--field-bg);
  border-radius: var(--radius-md);
  font-size: clamp(2.3rem, 3vw, 4rem);
  font-weight: 500;
  line-height: 1.15;
}

.screen--deep-admin .admin-side-panel {
  grid-template-rows: auto minmax(350px, 1fr) auto;
}

.manager-list {
  list-style: none;
  padding: 8px 22px 0 0;
}

.manager-list li {
  position: relative;
  min-height: 52px;
  padding: 15px 16px 15px 28px;
  background: #fff;
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
}

.manager-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 14px;
  margin-right: 22px;
  background: #fff;
  border-radius: var(--radius-sm);
}

.manager-form button {
  min-width: 64px;
}

@media (max-width: 1300px) {
  .app-shell {
    padding: 20px;
  }

  .screen--student,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .notice-panel,
  .admin-side-panel {
    min-height: 520px;
  }

  .notice-grid {
    max-height: none;
    min-height: 360px;
  }

  .admin-side-panel {
    grid-template-rows: auto auto auto auto;
  }
}

@media (max-width: 760px) {
  .top-bar,
  .admin-header,
  .deep-admin-header {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-controls,
  .admin-header,
  .deep-admin-header {
    width: 100%;
  }

  .profile-chip,
  .admin-header .profile-chip,
  .deep-admin-header .profile-chip {
    flex: 1 1 100%;
    min-width: 0;
    min-height: 64px;
    font-size: 2rem;
  }

  .view-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .screen--student {
    gap: 18px;
  }

  .panel-title,
  .notice-panel .panel-title {
    grid-template-columns: 64px minmax(0, 1fr);
    min-height: 62px;
  }

  .panel-title h2,
  .notice-panel .panel-title h2 {
    min-height: 62px;
    font-size: 2rem;
  }

  .panel-title span {
    width: 48px;
  }

  .period-list {
    grid-template-rows: repeat(7, minmax(64px, auto));
    min-height: auto;
  }

  .period-list li {
    font-size: 2.2rem;
  }

  .notice-panel {
    padding: 10px 26px 24px 12px;
  }

  .notice-grid {
    grid-template-columns: 1fr;
    padding-right: 18px;
  }

  .notice-card h3,
  .notice-card p {
    font-size: 1.1rem;
  }

  .matrix-panel {
    overflow-x: auto;
  }

  .timetable-matrix {
    min-width: 980px;
  }

  .deep-admin-header h1 {
    width: 100%;
    min-height: 64px;
    font-size: 2rem;
  }
}
