:root {
  --rku-blue: #102f60;
  --rku-red: #9e2127;
  --rku-lilac: #9395b2;
  --rku-beige: #c79277;
  --rku-gray: #b4b4b5;
  --rku-black: #000000;

  --bg: #f2f4f8;
  --panel: #ffffff;
  --panel-soft: #f8f9fd;
  --line: #d9dde8;
  --text: #1c2033;
  --muted: #5b6077;
  --accent: var(--rku-blue);
  --accent-weak: #e7ecf9;
  --danger: var(--rku-red);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background:
    radial-gradient(circle at 10% 0%, #ffffff 0, #f7f8fb 32%, #eceff6 100%),
    linear-gradient(150deg, #fefefe 0%, #f2f4f8 100%);
}

body.no-scroll {
  overflow: hidden;
}

.topbar {
  padding: 8px 16px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.24)),
    linear-gradient(132deg, rgba(24, 62, 122, 0.96), rgba(58, 102, 171, 0.9)),
    radial-gradient(circle at 82% 20%, rgba(196, 223, 255, 0.32), transparent 52%),
    radial-gradient(circle at 18% 72%, rgba(226, 240, 255, 0.26), transparent 56%);
  color: #fff;
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
}

.topbar-inner {
  max-width: 1520px;
  margin: 0 auto;
  padding: 4px 8px;
}

.brand-identity {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: fit-content;
  margin: 0 auto;
}

.brand-logo {
  width: 400px;
  height: 400px;
  border-radius: 0;
  background: transparent;
  border: none;
  padding: 0;
}

.brand-texts {
  text-align: left;
}

.brand-badge {
  margin: 0 0 6px;
  display: inline-block;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: 1.05rem;
}

.topbar #metaText {
  margin: 6px 0 0;
  opacity: 0.94;
}

.top-copy {
  margin: 0;
  font-size: clamp(1.02rem, 1.7vw, 1.24rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  opacity: 0.98;
}

.layout {
  max-width: 1520px;
  margin: 0 auto;
  padding: 18px;
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 18px;
  box-shadow: 0 16px 34px rgba(16, 47, 96, 0.08);
}

.search-panel {
  max-width: 1220px;
  margin: 0 auto;
  background:
    linear-gradient(180deg, #ffffff 0, #fcfdff 100%),
    radial-gradient(circle at 90% 0, rgba(147, 149, 178, 0.2), transparent 38%);
}

.search-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.search-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.layout-mode-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: #f6f8fc;
  border: 1px solid #dde5f2;
}

.layout-mode-tab {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: #5a6c91;
  border: 1px solid transparent;
  box-shadow: none;
  padding: 8px 14px;
}

.layout-mode-tab.active {
  background: linear-gradient(120deg, var(--rku-blue), #214d89);
  color: #fff;
  border-color: rgba(16, 47, 96, 0.2);
  box-shadow: 0 6px 14px rgba(16, 47, 96, 0.16);
}

.single-mode-back {
  white-space: nowrap;
}

.result-notice {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 14px;
  border: 1px solid #e4d7cb;
  background: linear-gradient(180deg, rgba(250, 242, 236, 0.92), rgba(250, 242, 236, 0.72));
  color: #6f5241;
  font-size: 0.92rem;
  line-height: 1.45;
}

h2,
h3,
h4,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 14px;
}

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

.form-grid label,
.form-grid fieldset {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.form-grid input,
.form-grid select,
button {
  font: inherit;
}

.form-grid input,
.form-grid select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
}

.search-targets {
  grid-column: span 2;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px 16px 14px;
  margin: 2px 0 0;
  background: var(--panel-soft);
}

.search-targets legend {
  padding: 0 8px;
  color: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 16px;
  border-radius: 999px;
  border: 1px solid #e2e8f4;
  background: rgba(255, 255, 255, 0.72);
  color: #62708c;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  cursor: pointer;
}

.chip input {
  accent-color: var(--rku-blue);
}

.chip-count {
  min-width: 2.1em;
  text-align: center;
  background: rgba(231, 236, 249, 0.55);
  color: #5e7198;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.1;
}

.mini-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.actions {
  grid-column: span 2;
  display: flex;
  gap: 8px;
}

button {
  border: 1px solid transparent;
  background: linear-gradient(120deg, var(--rku-blue), #214d89);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(16, 47, 96, 0.18);
}

button.ghost {
  background: #fff;
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: none;
}

button.ghost.danger {
  border-color: var(--danger);
  color: var(--danger);
}

button.small {
  padding: 6px 10px;
  font-size: 0.88rem;
}

.search-targets .ghost.small {
  border-color: #ccd9ef;
  color: #5e7198;
  background: rgba(255, 255, 255, 0.7);
  padding: 4px 9px;
  font-size: 0.84rem;
  line-height: 1.2;
}

.search-targets .ghost.small.toggle-on {
  background: linear-gradient(120deg, #c1222c, #8f1a22);
  color: #fff;
  border-color: #7f1620;
  box-shadow: 0 0 0 2px rgba(193, 34, 44, 0.2), 0 8px 16px rgba(127, 22, 32, 0.25);
}

.search-targets .ghost.small.toggle-off {
  background: rgba(193, 34, 44, 0.12);
  color: #8f1a22;
  border-color: rgba(193, 34, 44, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

button:disabled {
  opacity: 0.46;
  cursor: default;
}

.result-header {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.result-list,
.selected-list {
  display: grid;
  gap: 10px;
}

.course-card,
.selected-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px;
}

.course-card {
  background:
    linear-gradient(135deg, rgba(231, 236, 249, 0.4), transparent 35%),
    linear-gradient(0deg, #fff, #fff);
}

.course-card h4,
.selected-card h4 {
  margin-bottom: 8px;
}

.meta {
  color: var(--muted);
  margin-bottom: 6px;
}

.preview {
  line-height: 1.52;
  margin: 10px 0 2px;
}

.card-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pager {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.hidden {
  display: none;
}

.timetable-panel {
  max-width: 1220px;
  margin: 16px auto 0;
}

.timetable-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.timetable-head-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.timetable-head-main h2 {
  margin-bottom: 0;
}

.timetable-semester-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: #eef2fb;
  border: 1px solid #d7dfef;
}

.semester-tab {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: #5a6c91;
  border: 1px solid transparent;
  box-shadow: none;
  padding: 8px 14px;
}

.semester-tab.active {
  background: linear-gradient(120deg, var(--rku-blue), #214d89);
  color: #fff;
  border-color: rgba(16, 47, 96, 0.2);
  box-shadow: 0 6px 14px rgba(16, 47, 96, 0.16);
}

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

.mobile-only-close {
  display: none;
}

.conflict-summary {
  font-weight: 700;
  color: var(--rku-red);
}

.timetable-section + .timetable-section {
  margin-top: 8px;
}

.timetable-grid {
  margin-bottom: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tt-table {
  width: 100%;
  min-width: 640px;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.tt-table th,
.tt-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px;
  vertical-align: top;
}

.tt-table tr:last-child td,
.tt-table tr:last-child th {
  border-bottom: none;
}

.tt-table th:last-child,
.tt-table td:last-child {
  border-right: none;
}

.tt-table th {
  background: linear-gradient(180deg, #edf2ff, #e8eef8);
}

.tt-item {
  background: linear-gradient(180deg, #eaf0ff, #f2f5ff);
  border: 1px solid #cfd8ec;
  border-radius: 12px;
  padding: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.tt-table td.conflict {
  background: #fdebed;
}

.conflict-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.conflict-card {
  border: 1px solid #f0c7cd;
  background: #fff8f9;
  border-radius: 16px;
  padding: 12px;
}

.empty {
  color: var(--muted);
}

dialog {
  border: none;
  border-radius: 24px;
  width: min(980px, 92vw);
  max-height: 90vh;
  overflow: auto;
  padding: 0;
  background: #fff;
}

dialog::backdrop {
  background: rgba(16, 47, 96, 0.42);
}

dialog article {
  padding: 16px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.detail-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
  box-shadow: none;
}

.tab-btn.active {
  background: linear-gradient(120deg, var(--rku-blue), #264f89);
  color: #fff;
}

.tab-panel.hidden {
  display: none;
}

.detail-section {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.detail-section h4 {
  margin-bottom: 6px;
  color: var(--accent);
}

.detail-section p {
  margin: 0;
  line-height: 1.64;
}

.schedule-list {
  display: grid;
  gap: 10px;
}

.schedule-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background:
    linear-gradient(145deg, rgba(147, 149, 178, 0.12), transparent 28%),
    #fff;
}

.schedule-card.pinned {
  border-color: #9aafdc;
  background:
    linear-gradient(145deg, rgba(16, 47, 96, 0.11), rgba(255, 255, 255, 0.96) 40%),
    #fff;
}

.pin-label {
  margin: 0 0 6px;
  display: inline-block;
  background: var(--rku-red);
  color: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 800;
  font-size: 0.78rem;
}

.schedule-card h4 {
  margin-bottom: 8px;
  color: var(--rku-blue);
}

.schedule-card p {
  margin: 0 0 8px;
  line-height: 1.6;
}

.schedule-card p:last-child {
  margin-bottom: 0;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.compare-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: #fff;
}

.compare-card h4 {
  margin-bottom: 8px;
  color: var(--rku-blue);
}

.compare-card p {
  margin: 0 0 8px;
  line-height: 1.55;
}

.compare-card p:last-child {
  margin-bottom: 0;
}

.compare-card .adopt-btn {
  background: linear-gradient(120deg, #c1222c, #8f1a22);
  border-color: #7f1620;
  color: #fff;
  box-shadow: 0 6px 14px rgba(127, 22, 32, 0.24);
}

.site-footer {
  margin-top: 28px;
  padding: 22px 16px 28px;
  color: #24334f;
}

.site-footer-inner {
  max-width: 1520px;
  margin: 0 auto;
  border-top: 1px solid #cfd8ea;
  padding-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 0.92rem;
}

.site-footer p {
  margin: 0;
  color: #3f4e6a;
}

.timetable-fab {
  display: none;
}

@media (max-width: 1060px) {
  .search-panel {
    max-width: none;
  }

  .brand-logo {
    width: 300px;
    height: 300px;
  }

  .top-copy {
    font-size: clamp(0.94rem, 1.5vw, 1.08rem);
  }
}

@media (min-width: 1200px) {
  .layout.with-timetable {
    display: grid;
    grid-template-columns: minmax(700px, 1.15fr) minmax(380px, 0.85fr);
    gap: 16px;
    align-items: start;
  }

  .layout.with-timetable .search-panel,
  .layout.with-timetable .timetable-panel {
    max-width: none;
    margin: 0;
  }

  .layout.with-timetable .timetable-panel {
    position: sticky;
    top: 14px;
    max-height: calc(100vh - 28px);
    overflow: auto;
  }
}

@media (max-width: 680px) {
  .topbar {
    border-radius: 0 0 22px 22px;
    padding: 6px 12px;
  }

  .layout {
    padding: 12px;
  }

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

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

  .actions,
  .search-targets {
    grid-column: span 1;
  }

  .timetable-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .timetable-head-main,
  .head-actions {
    width: 100%;
  }

  .timetable-semester-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .layout-mode-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .search-head-actions {
    width: 100%;
    justify-content: stretch;
  }

  .layout-mode-tab,
  .semester-tab {
    flex: 1 1 0;
    justify-content: center;
  }

  .timetable-semester-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .semester-tab {
    flex: 1 1 0;
    justify-content: center;
  }

  .search-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .single-mode-back {
    width: 100%;
    justify-content: center;
  }

  #toggleTimetableBtn {
    display: none;
  }

  .brand-logo {
    width: 200px;
    height: 200px;
    padding: 0;
  }

  .brand-badge {
    font-size: 0.92rem;
    padding: 8px 12px;
    margin-bottom: 8px;
  }

  .topbar-inner {
    padding: 4px 6px;
  }

  .brand-identity {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .brand-texts {
    text-align: center;
  }

  .top-copy {
    font-size: 0.96rem;
    line-height: 1.45;
  }

  .topbar #metaText {
    font-size: 0.95rem;
  }

  .detail-tabs {
    flex-wrap: wrap;
  }

  .mobile-only-close {
    display: inline-flex;
  }

  .timetable-fab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    right: 14px;
    bottom: 16px;
    z-index: 1300;
    border-radius: 999px;
    padding: 11px 14px;
    background: linear-gradient(120deg, var(--rku-blue), #2f5f9f);
    color: #fff;
    border: none;
    box-shadow: 0 10px 20px rgba(16, 47, 96, 0.32);
    font-weight: 800;
  }

  .timetable-fab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.8em;
    height: 1.8em;
    border-radius: 999px;
    padding: 0 6px;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.38);
    font-size: 0.82rem;
  }

  .timetable-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    top: auto;
    margin: 0;
    max-width: none;
    max-height: min(82vh, 760px);
    overflow: auto;
    z-index: 1250;
    border-radius: 18px;
    transform: translateY(120%);
    opacity: 0;
    pointer-events: none;
    transition: transform 180ms ease, opacity 180ms ease;
    box-shadow: 0 20px 44px rgba(14, 34, 70, 0.36);
  }

  .timetable-panel.mobile-popup-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
}
