:root {
  --paper: #fcfcfa;
  --ink: #191a17;
  --muted: #74766e;
  --rule: #e4e5e0;
  --late: #a32d1f;
  --school: #3f5d8c;
  --work: #7a5230;
  --make: #4a6b47;
  --life: #6b5a7d;
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  padding: 3rem 1.25rem 7rem;
  max-width: 44rem;
  background: var(--paper);
  color: var(--ink);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: "tnum";
}

a { color: inherit; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ヘッダ: 日付と件数が主役 */
.head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--ink);
}

.today { font-size: 1.75rem; font-weight: 600; letter-spacing: -0.01em; }
.today .dow { margin-left: 0.5rem; font-size: 0.9rem; font-weight: 400; color: var(--muted); }
.count { color: var(--muted); }
.sync { margin-left: auto; }
.sync button { color: var(--muted); border-bottom: 1px solid var(--rule); }
.sync button:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* 絞り込み */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem 0 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.filters a { text-decoration: none; }
.filters a:hover { color: var(--ink); }
.filters a.on { color: var(--ink); font-weight: 600; }
.filters .right { margin-left: auto; }

/* 時間の束 */
.bucket { margin-bottom: 2.25rem; }
.bucket h2 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.bucket.late h2 { color: var(--late); }

.bucket ul { margin: 0; padding: 0; list-style: none; }

.item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--rule);
}
.item:last-child { border-bottom: 1px solid var(--rule); }

.bucket.late .item { box-shadow: inset 2px 0 0 var(--late); padding-left: 0.75rem; }

.check button {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.2rem;
  border: 1px solid var(--muted);
  border-radius: 50%;
  font-size: 0.7rem;
  line-height: 1;
}
.check button:hover { border-color: var(--ink); background: #fff; }

.item time {
  min-width: 5.5rem;
  padding-top: 0.05rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.bucket.late time { color: var(--late); }

.body { flex: 1; min-width: 0; }
.title { font-weight: 500; }
a.title:hover { text-decoration-thickness: 2px; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.area { font-weight: 600; }
.area-school { color: var(--school); }
.area-work   { color: var(--work); }
.area-make   { color: var(--make); }
.area-life   { color: var(--life); }

.is-done .title { color: var(--muted); text-decoration: line-through; }

.del button { color: var(--rule); font-size: 1rem; }
.del button:hover { color: var(--late); }

.empty { padding: 3rem 0; color: var(--muted); }

/* 追加フォーム */
.add {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--paper);
  border-top: 1px solid var(--ink);
}
.add > * { max-width: 100%; }
.add input[type="text"] { flex: 1; min-width: 8rem; }
.add input, .add select {
  padding: 0.35rem 0.5rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 3px;
  font: inherit;
}
.add button {
  padding: 0.35rem 1rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 3px;
}

@media (max-width: 560px) {
  body { padding-top: 1.5rem; }
  .add { flex-wrap: wrap; }
  .item time { min-width: 4.5rem; }
}

/* ---- 科目・時間割・お知らせ（ここから追加分） ---- */

.nav-link {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.head .sync { margin-left: .75rem; }

.synclog {
  margin: -.5rem 0 1.25rem;
  font-size: 12px;
  color: var(--muted);
}
.synclog span { margin-left: .6rem; }

.timetable {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
  padding: .9rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fff;
}
.tt-col { flex: 1; min-width: 0; }
.tt-col h3 {
  margin: 0 0 .4rem;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 600;
}
.tt-col ol { margin: 0; padding: 0; list-style: none; }
.tt-col li { display: flex; gap: .5rem; align-items: baseline; padding: .15rem 0; }
.tt-col li b { font-size: 12px; color: var(--school); white-space: nowrap; }
.tt-col li a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.tt-col .room { font-size: 12px; color: var(--muted); }
.tt-col .none { margin: 0; font-size: 13px; color: var(--muted); }

.scope {
  display: flex;
  gap: .75rem;
  align-items: baseline;
  margin-bottom: 1rem;
  font-size: 13px;
  color: var(--muted);
}

.meta .course {
  color: var(--school);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.meta .ext {
  padding: 0 .35rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-size: 11px;
}
.meta .ext-missing { color: var(--late); border-color: var(--late); }
.meta .ext-graded, .meta .ext-submitted { color: var(--make); border-color: var(--make); }
.meta .score { font-size: 11px; color: var(--muted); }

.bucket.notes .item { opacity: .85; }
.bucket.notes .item time { color: var(--muted); }

/* 科目ページ */
.course-card {
  margin-bottom: 1.25rem;
  padding: .9rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fff;
}
.course-card.past { opacity: .6; }
.course-card h2 { margin: 0 0 .35rem; font-size: 16px; }
.course-card h2 a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.course-facts {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  font-size: 12px;
  color: var(--muted);
}
.course-facts .slot { color: var(--school); font-weight: 600; }
.course-facts .open-count { color: inherit; text-decoration: none; border-bottom: 1px solid var(--rule); }
.course-facts .absence.danger { color: var(--late); font-weight: 600; }
.course-card .grading, .course-card .memo {
  margin: .5rem 0 0;
  font-size: 13px;
  color: var(--muted);
}

.course-edit { margin-top: .6rem; }
.course-edit summary {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.course-edit form { margin-top: .6rem; }
.course-edit .row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .5rem;
}
.course-edit label {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  font-size: 11px;
  color: var(--muted);
}
.course-edit label.wide { display: block; margin-bottom: .5rem; }
.course-edit input, .course-edit select, .course-edit textarea {
  font: inherit;
  font-size: 13px;
  padding: .3rem .4rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}
.course-edit input[type="number"] { width: 5rem; }
.course-edit textarea { width: 100%; resize: vertical; }
.course-edit button {
  padding: .35rem .9rem;
  border: 1px solid var(--ink);
  border-radius: 4px;
  font-size: 13px;
}

@media (max-width: 34rem) {
  .timetable { flex-direction: column; gap: 1rem; }
}

/* ---- ログイン・スマホ（ここから追加分） ---- */

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login {
  width: min(22rem, 100%);
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
}
.login h1 { margin: 0 0 1rem; font-size: 18px; }
.login input {
  width: 100%;
  font: inherit;
  padding: .7rem .6rem;
  margin-bottom: .75rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.login button {
  width: 100%;
  padding: .7rem;
  border: 1px solid var(--ink);
  border-radius: 6px;
}
.login .err { margin: .75rem 0 0; color: var(--late); font-size: 13px; }
.login .warn { margin: 0 0 1rem; font-size: 12px; color: var(--muted); line-height: 1.5; }

.head .logout { margin-left: .6rem; }
.head .logout button { font-size: 12px; color: var(--muted); }

/* スマホ。指で押せる大きさを確保し、横に詰め込まない。 */
@media (max-width: 34rem) {
  body { padding: 1.25rem .9rem 6rem; font-size: 16px; }

  .head { flex-wrap: wrap; gap: .5rem .75rem; }
  .nav-link { margin-left: 0; }

  .item .check button,
  .item .del button { min-width: 2.75rem; min-height: 2.75rem; }

  .item .title { line-height: 1.5; }

  .add {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
    padding: .75rem 0;
    background: var(--paper);
    border-top: 1px solid var(--rule);
  }
  .add input[type="text"] { grid-column: 1 / -1; }
  .add button { grid-column: 1 / -1; padding: .7rem; border: 1px solid var(--ink); border-radius: 6px; }
  .add input, .add select { padding: .6rem .5rem; font-size: 16px; }

  .course-edit .row { flex-direction: column; gap: .5rem; }
  .course-edit input[type="number"] { width: 100%; }
}

/* 入力欄の文字が16px未満だと iOS が勝手に拡大する */
input, select, textarea { font-size: max(16px, 1em); }

/* ---- 接続ページ ---- */
.nav-link2 {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  margin-left: .75rem;
}
.conn-error {
  padding: .6rem .8rem;
  border: 1px solid var(--late);
  border-radius: 6px;
  color: var(--late);
  font-size: 13px;
}
.conn-form { margin-top: .7rem; }
.conn-form button {
  padding: .5rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 13px;
}
.conn-form button.primary { border-color: var(--ink); font-weight: 600; }
.course-card code {
  font-size: 12px;
  padding: .1rem .3rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  word-break: break-all;
}
.add .to-google {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
@media (max-width: 34rem) {
  .add .to-google { grid-column: 1 / -1; }
  .nav-link2 { margin-left: 0; }
}

/* ---- プライバシーポリシー ---- */
.policy { max-width: 38rem; line-height: 1.85; }
.policy h2 {
  margin: 2rem 0 .5rem;
  font-size: 14px;
  letter-spacing: .04em;
  padding-bottom: .3rem;
  border-bottom: 1px solid var(--rule);
}
.policy p, .policy li { font-size: 14px; }
.policy ul { padding-left: 1.2rem; }
.policy li { margin: .2rem 0; }
.policy a { color: var(--school); }
.policy code {
  font-size: 12px;
  padding: .1rem .3rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
}
.policy-updated { margin-top: 2.5rem; font-size: 12px; color: var(--muted); }

/* ---- シラバス ---- */
.syllabus {
  margin-top: .7rem;
  padding: .6rem .75rem;
  border-left: 3px solid var(--school);
  background: var(--paper);
  border-radius: 0 4px 4px 0;
}
.syl-label {
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .25rem;
}
.syl-label a { font-size: 11px; color: var(--school); margin-left: .5rem; }
.syllabus p { margin: 0; font-size: 13px; line-height: 1.7; }
.syl-plan { margin-top: .6rem; }
.syl-plan summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.syl-plan ol { margin: .5rem 0 0; padding-left: 0; list-style: none; }
.syl-plan li {
  font-size: 12px;
  line-height: 1.6;
  padding: .3rem 0;
  border-top: 1px solid var(--rule);
}
.syl-plan li b { display: inline-block; min-width: 1.8em; color: var(--school); }

/* ---- 時間割表 ---- */
/* 7列あるのでスマホでは収まらない。表だけ横スクロールさせ、
   ページ本体は横スクロールさせない。 */
.tt-wrap { overflow-x: auto; margin-bottom: 1.5rem; }
.tt {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-size: 13px;
}
.tt th, .tt td {
  border: 1px solid var(--rule);
  vertical-align: top;
  padding: .4rem .45rem;
}
.tt thead th {
  background: var(--paper);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: .35rem;
}
.tt-corner { border-top: none; border-left: none; background: transparent !important; }
.tt-period {
  width: 2rem;
  text-align: center;
  color: var(--muted);
  font-weight: 400;
  background: var(--paper);
}
.tt td { height: 3.6rem; background: #fff; }
.tt td.filled { background: #fff; }
.tt td a {
  display: block;
  line-height: 1.4;
  text-decoration: none;
  color: var(--ink);
}
.tt td a:hover { text-decoration: underline; }
.tt-room { display: block; font-size: 11px; color: var(--muted); margin-top: .15rem; }
.tt-open {
  display: inline-block;
  margin-top: .2rem;
  padding: 0 .3rem;
  border: 1px solid var(--late);
  border-radius: 3px;
  font-size: 10px;
  color: var(--late);
}
.tt th.is-today { color: var(--school); }
.tt td.is-today { background: #f6f8fc; }
