/* 校园一周歌单 —— 布局：顶部可折叠设置条 + 输入/结果并排
   圆角：连续曲率（超椭圆），Chrome / Edge 139+ 生效，其余浏览器退回普通圆角 */

:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-soft: #fafbf8;
  --line: #e4e7e2;
  --line-strong: #d3d8d0;
  --ink: #1a2320;
  --ink-2: #48544d;
  --muted: #7b857e;
  --accent: #2e6b4f;
  --accent-deep: #245640;
  --accent-soft: #e9f1eb;
  --warn: #8a5a2b;
  --warn-bg: #fbf3e8;
  --warn-line: #e2cdb2;

  /* 连续曲率半径比圆弧半径略大，观感才接近 */
  --r-card: 26px;
  --r-field: 13px;
  --r-small: 10px;

  --shadow: 0 1px 2px rgba(24, 32, 27, 0.04), 0 20px 44px -34px rgba(24, 32, 27, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI Variable Text", "Segoe UI", -apple-system, "PingFang SC",
    "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1360px;
  margin: 0 auto;
  padding: 40px 24px 48px;
}

/* 连续曲率：一处声明，全局生效；不支持时该属性被忽略，只留 border-radius */
.panel,
.table-wrap,
.empty-state,
.notice,
.unused,
.btn,
.masthead .brand-mark,
.brand-mark--lg,
.lock-card,
.lock-input,
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea,
.day-chip {
  corner-shape: squircle;
}

/* ---------------------------------------------------------------- 页头 */

.masthead {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand-mark {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  width: 40px;
  height: 40px;
  padding: 10px;
  border-radius: 12px;
  background: var(--accent);
  flex: none;
}

.brand-mark i {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.92);
}
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 16px; }
.brand-mark i:nth-child(3) { height: 11px; }
.brand-mark i:nth-child(4) { height: 5px; }

.brand-text h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-text p {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.masthead-note {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- 卡片基础 */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.hint {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- 设置条 */

.settings { padding: 18px 24px; }

.settings-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 30px;
}

.settings-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.settings-summary {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.settings-body[hidden] { display: none; }
.settings-body { animation: reveal 0.18s ease both; }

@keyframes reveal {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}

.settings-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.3fr 0.75fr;
  gap: 22px;
  margin-top: 18px;
  align-items: stretch;
}

/* 三列等高：每列都是纵向 flex，textarea 撑满，底边对齐 */
.settings-grid .group {
  display: flex;
  flex-direction: column;
}

.settings-body textarea {
  flex: 1;
  min-height: 126px;
}

.settings-grid .field--grow {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.settings-grid .field--grow textarea { flex: 1; }

.settings-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.settings-foot .field-note { margin: 0; }

/* ---------------------------------------------------------------- 表单 */

.group h3 {
  margin: 0 0 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.field {
  display: block;
  margin-bottom: 10px;
}
.field:last-child { margin-bottom: 0; }

.field-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 5px;
  font-size: 11.5px;
  color: var(--ink-2);
}

.field-label em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  background: var(--surface-soft);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.55;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea { resize: vertical; min-height: 92px; }

input:hover,
select:hover,
textarea:hover { border-color: var(--line-strong); }

input:focus,
select:focus,
textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 107, 79, 0.12);
}

.field-note {
  margin: 6px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease,
    box-shadow 0.16s ease, opacity 0.16s ease;
  white-space: nowrap;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(36, 86, 64, 0.22);
}
.btn--primary:hover { background: var(--accent-deep); }
.btn--primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-2);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--muted);
  color: var(--ink);
}
.btn--ghost:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--small { padding: 6px 13px; font-size: 12.5px; }

/* ---------------------------------------------------------------- 主区 */

.layout {
  display: grid;
  grid-template-columns: 0.88fr 1.12fr;
  gap: 20px;
  margin-top: 20px;
  align-items: stretch;
}

.panel--input,
.panel--result {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  /* grid 项默认 min-width:auto，会被表格的固有宽度撑开，这里放开让表格自己横向滚动 */
  min-width: 0;
}

.songs-input {
  flex: 1;
  min-height: 300px;
  margin-bottom: 0;
  font-size: 14px;
  line-height: 1.95;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.status {
  font-size: 12px;
  color: var(--muted);
}

.status.is-busy { color: var(--accent); }

/* ---------------------------------------------------------------- 提示 */

.notice {
  margin-top: 14px;
  padding: 10px 13px;
  border-left: 3px solid var(--warn);
  border-radius: var(--r-small);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-line;
}

.notice ul { margin: 4px 0 0; padding-left: 18px; white-space: normal; }

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.01em;
}

.empty-state p { margin: 0; }

/* hidden 属性要能压过上面的 display:flex */
.empty-state[hidden] { display: none; }

/* ---------------------------------------------------------------- 结果表格 */

.summary {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.summary:empty { display: none; }

#result-notice { margin: 0 0 12px; }

.table-wrap {
  flex: 1;
  min-height: 0;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.plan-table {
  width: 100%;
  border-collapse: collapse;
}

.plan-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 12px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

/* 第一列「第 N 首」：横向滚动时钉在最左边 */
.plan-table .col-step {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 72px;
  min-width: 72px;
  padding: 9px 10px;
  background: var(--surface-soft);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.plan-table thead th.col-step { z-index: 3; color: var(--muted); }

.plan-table thead th .theme-text {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
  white-space: normal;
}

/* 列宽随卡片宽度等分：一周 5–7 天都不出现横向滚动 */
.plan-table thead th:not(.col-step),
.plan-table tbody td { min-width: 84px; }

.plan-table tbody td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.plan-table tbody tr:last-child td,
.plan-table tbody tr:last-child .col-step { border-bottom: none; }

.plan-table tbody tr:hover td,
.plan-table tbody tr:hover .col-step { background: #fcfdfb; }

.cell-empty {
  font-size: 12px;
  color: var(--muted);
}

.day-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.theme-text {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.7;
}

.song-title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.6;
  word-break: break-word;
}

.song-reason {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.55;
}

.tag-outside {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border: 1px solid var(--warn-line);
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--warn);
  background: var(--warn-bg);
  vertical-align: 1px;
}

.tag-ai {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border: 1px solid #cfdcd3;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--accent-deep);
  background: var(--accent-soft);
  vertical-align: 1px;
}

.unused {
  margin-top: 12px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-small);
  background: var(--surface-soft);
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.8;
}

.unused strong { font-weight: 600; color: var(--ink); }

/* ---------------------------------------------------------------- 解锁遮罩 */

.page[hidden],
.lock[hidden] { display: none; }

.lock {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(243, 244, 241, 0.94);
  backdrop-filter: blur(10px);
}

.lock-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: min(400px, 100%);
  margin: 0;
  padding: 30px 28px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: 0 18px 44px rgba(26, 35, 32, 0.1);
  text-align: center;
}

.brand-mark--lg {
  align-self: center;
  width: 46px;
  height: 46px;
  gap: 3px;
}

.brand-mark--lg i { width: 4px; }

.lock-card h1 {
  margin: 8px 0 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.lock-note {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  text-wrap: pretty;
}

.lock-input {
  width: 100%;
  height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-field);
  background: var(--surface-soft);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-align: center;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.lock-input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(46, 107, 79, 0.12);
}

.lock-card .btn {
  height: 40px;
  font-size: 14px;
}

.lock-error {
  min-height: 17px;
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--warn);
}

/* ---------------------------------------------------------------- 页脚 */

.foot {
  margin-top: 28px;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

/* 不支持连续曲率时的退让：圆弧半径调小，观感更接近 */
@supports not (corner-shape: squircle) {
  :root {
    --r-card: 20px;
    --r-field: 10px;
    --r-small: 8px;
  }
  .btn { border-radius: 10px; }
  .table-wrap { border-radius: 12px; }
}

/* ---------------------------------------------------------------- 响应式 */

@media (max-width: 1020px) {
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .layout { grid-template-columns: 1fr; }
  .panel--input, .panel--result { min-height: 0; }
  .panel--result { min-height: 380px; }
  .songs-input { min-height: 220px; }
}

/* 手机宽度下等分列会挤到看不清，这时允许表格内部横向滚动 */
@media (max-width: 720px) {
  .plan-table thead th:not(.col-step),
  .plan-table tbody td { min-width: 88px; }
}

@media (max-width: 720px) {
  .page { padding: 28px 16px 36px; }
  .panel { padding: 18px 18px; }
  .settings-grid { grid-template-columns: 1fr; gap: 18px; }
  .settings-head { flex-wrap: wrap; }
  .settings-summary { order: 3; flex-basis: 100%; white-space: normal; }
  .masthead-note { display: none; }
  .settings-foot { flex-direction: column; align-items: stretch; }
  .settings-foot .btn { width: 100%; }
}
