:root {
  color-scheme: light;
  --ink: #172331;
  --muted: #687586;
  --line: #d9d5ca;
  --paper: #fffdf8;
  --canvas: #f5f1e8;
  --navy: #1d3d55;
  --navy-soft: #e6eef3;
  --accent: #c8663d;
  --green: #26705c;
  --shadow: 0 12px 36px rgba(44, 52, 57, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% -10%, rgba(200, 102, 61, 0.11), transparent 34rem),
    var(--canvas);
  color: var(--ink);
}

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

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(430px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 10px; }
.auth-copy { color: var(--muted); line-height: 1.5; }
.auth-form { display: grid; gap: 15px; margin-top: 20px; }
.auth-form .primary-action { min-height: 48px; }
.auth-status { min-height: 1.4em; margin: 14px 0 0; color: var(--muted); font-size: .88rem; }
.auth-status.error { color: #8f352d; }

.app-header,
main {
  width: min(980px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: max(28px, env(safe-area-inset-top)) 0 22px;
}
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.quiet-button { min-height: 40px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,253,248,.78); color: var(--navy); font-weight: 750; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 2px; font-family: Georgia, serif; font-size: clamp(2rem, 5vw, 3rem); font-weight: 600; letter-spacing: -0.035em; }
.owner { margin-bottom: 0; color: var(--muted); }

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.76);
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
}

.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #d89d3a; }

.view-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.view-tabs { display: flex; gap: 4px; }
.tab, .today-button, .icon-button, .primary-action, .secondary-action {
  min-height: 44px;
  border-radius: 12px;
  border: 0;
  font-weight: 750;
}
.tab { padding: 0 17px; background: transparent; color: var(--muted); }
.tab.active { background: var(--navy); color: #fff; }

.date-nav { display: flex; align-items: center; gap: 8px; }
.icon-button { width: 44px; background: #ede9df; color: var(--navy); font-size: 1.7rem; }
.today-button { padding: 0 14px; background: var(--navy-soft); color: var(--navy); }
.date-control { display: grid; gap: 2px; color: var(--muted); font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.date-control input { width: 142px; border: 0; background: transparent; color: var(--ink); font-size: 0.96rem; font-weight: 700; }
.class-control { display: grid; gap: 3px; min-width: 260px; color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.class-control select { min-height: 40px; border: 0; background: transparent; color: var(--ink); font-weight: 700; }

.day-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding: 38px 2px 16px; }
.day-heading h2 { margin-bottom: 0; font-family: Georgia, serif; font-size: clamp(1.7rem, 4vw, 2.35rem); font-weight: 600; }
.day-count { margin-bottom: 5px; color: var(--muted); font-size: 0.9rem; font-weight: 700; }

.lesson-list { display: grid; gap: 14px; padding-bottom: max(36px, env(safe-area-inset-bottom)); }
.lesson-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.lesson-time { padding: 24px 18px; border-right: 1px solid var(--line); background: #f0ece2; }
.lesson-time strong, .lesson-time span { display: block; }
.lesson-time strong { font-size: 1.08rem; }
.lesson-time span { margin-top: 5px; color: var(--muted); font-size: 0.84rem; }
.lesson-main { padding: 22px 24px 24px; }
.lesson-title-row { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.subject { margin-bottom: 3px; color: var(--muted); font-size: 0.84rem; font-weight: 720; }
.lesson-title-row h3 { margin-bottom: 0; font-family: Georgia, serif; font-size: 1.65rem; }
.state-badge { padding: 7px 10px; border-radius: 999px; background: #edf2ee; color: var(--green); font-size: 0.74rem; font-weight: 800; }
.summary-block { margin-top: 18px; padding: 15px 16px; border-left: 3px solid var(--accent); border-radius: 0 12px 12px 0; background: #f8f4ec; }
.summary-label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.provisional-tag { padding: 4px 7px; border-radius: 999px; background: #f7e8bf; color: #755a17; font-size: .7rem; font-weight: 800; }
.label { margin-bottom: 6px; color: var(--accent); font-size: 0.72rem; font-weight: 850; letter-spacing: 0.1em; text-transform: uppercase; }
.summary-text { margin-bottom: 0; line-height: 1.55; white-space: pre-line; }
.summary-text.empty { color: var(--muted); font-style: italic; }
.card-actions { display: flex; gap: 10px; margin-top: 18px; }
.primary-action, .secondary-action { padding: 0 16px; }
.primary-action { background: var(--navy); color: white; }
.secondary-action { border: 1px solid var(--line); background: transparent; color: var(--navy); }
.continuity-block { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: #eaf2ef; color: #28483e; }
.continuity-block p { margin-bottom: 0; line-height: 1.5; }
.continuity-label { margin-bottom: 5px !important; color: var(--green); }
.record-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.field { display: grid; gap: 6px; }
.field > span, .status-field legend { color: var(--muted); font-size: .76rem; font-weight: 800; letter-spacing: .04em; }
.field input, .field textarea, .field select, .move-dialog select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cfc9bc; border-radius: 11px; background: #fff; color: var(--ink); }
.field textarea { resize: vertical; line-height: 1.5; }
.full-field { grid-column: 1 / -1; }
.status-field { grid-column: 1 / -1; display: flex; gap: 18px; align-items: center; min-height: 44px; margin: 0; padding: 0; border: 0; }
.status-field legend { float: left; margin-right: 8px; }
.status-field label { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.prediction-editor { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.prediction-editor summary { color: var(--navy); font-weight: 750; cursor: pointer; }
.prediction-editor .field { margin-top: 12px; }
.prediction-editor .form-actions { margin-top: 10px; }
.week-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.week-day { min-height: 180px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,253,248,.76); }
.week-day.current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.week-day button { width: 100%; border: 0; background: none; color: inherit; text-align: left; }
.week-day h3 { margin-bottom: 4px; font-family: Georgia, serif; }
.week-day-date { color: var(--muted); font-size: .78rem; }
.week-lesson { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.week-lesson strong, .week-lesson span { display: block; }
.week-lesson span { margin-top: 2px; color: var(--muted); font-size: .78rem; }
.move-dialog { width: min(520px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 20px; padding: 24px; background: var(--paper); color: var(--ink); box-shadow: 0 24px 80px rgba(18,31,41,.22); }
.move-dialog::backdrop { background: rgba(23,35,49,.55); backdrop-filter: blur(3px); }
.move-dialog h2 { font-family: Georgia, serif; }
.dialog-copy, .dialog-note { color: var(--muted); line-height: 1.5; }
.dialog-note { font-size: .82rem; }
.move-dialog .form-actions { margin-top: 18px; }
.absence-action { margin-left: auto; }
.absence-dialog { width: min(900px, calc(100% - 24px)); max-height: 92vh; overflow: auto; border: 1px solid var(--line); border-radius: 22px; padding: 22px; background: var(--paper); color: var(--ink); box-shadow: 0 24px 80px rgba(18,31,41,.25); }
.absence-dialog::backdrop { background: rgba(23,35,49,.6); backdrop-filter: blur(3px); }
.dialog-header { display: flex; justify-content: space-between; align-items: start; gap: 18px; }
.absence-dialog h2 { margin-bottom: 2px; font-family: Georgia, serif; }
.dialog-close { width: 44px; height: 44px; border: 0; border-radius: 50%; background: #ede9df; color: var(--navy); font-size: 1.6rem; }
.absence-help { margin: 10px 0 16px; color: var(--muted); }
.roster-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9px; }
.student-toggle { position: relative; display: grid; grid-template-rows: 92px auto; min-width: 0; overflow: hidden; border: 2px solid transparent; border-radius: 13px; background: #f0ece2; color: var(--ink); text-align: left; }
.student-toggle img { width: 100%; height: 92px; object-fit: cover; object-position: center top; background: #e5e0d6; }
.student-toggle span { min-height: 53px; padding: 7px; font-size: .72rem; font-weight: 750; line-height: 1.25; }
.student-toggle small { display: block; color: var(--muted); font-size: .65rem; }
.student-toggle.selected { border-color: #a83f32; background: #f8e7e4; }
.student-toggle.selected::after { content: "Ausente"; position: absolute; top: 6px; right: 6px; padding: 4px 6px; border-radius: 999px; background: #a83f32; color: #fff; font-size: .6rem; font-weight: 850; text-transform: uppercase; }
.absence-summary { margin: 15px 0; color: #8f352d; }
.app-footer { width: min(980px, calc(100% - 32px)); margin: 18px auto 34px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.app-footer > div { padding: 16px; border-top: 1px solid var(--line); }
.app-footer strong { color: var(--navy); }
.app-footer p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.toast { position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 20; max-width: calc(100% - 36px); padding: 12px 16px; border-radius: 12px; background: var(--navy); color: white; box-shadow: var(--shadow); font-weight: 700; }

.empty-state { padding: 46px 24px; border: 1px dashed #c9c3b6; border-radius: 20px; text-align: center; background: rgba(255,253,248,.65); }
.empty-state h3 { margin-bottom: 8px; font-family: Georgia, serif; font-size: 1.55rem; }
.empty-state p { margin: 0 auto 18px; max-width: 470px; color: var(--muted); line-height: 1.55; }

@media (max-width: 680px) {
  .app-header { align-items: flex-start; padding-bottom: 16px; }
  .header-actions { max-width: 150px; }
  .sync-pill span:last-child { display: none; }
  .header-actions .quiet-button { min-height: 36px; padding-inline: 9px; font-size: .78rem; }
  .view-shell { align-items: stretch; flex-direction: column; }
  .view-tabs { display: grid; grid-template-columns: repeat(3, 1fr); }
  .date-nav { justify-content: space-between; }
  .today-button { display: none; }
  .lesson-card { grid-template-columns: 1fr; }
  .lesson-time { display: flex; gap: 7px; padding: 14px 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .lesson-time span { margin-top: 0; }
  .lesson-time span::before { content: "– "; }
  .lesson-main { padding: 19px 18px 20px; }
  .card-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .absence-action { grid-column: 1 / -1; margin-left: 0; }
  .primary-action, .secondary-action { min-height: 48px; padding-inline: 8px; }
  .record-form { grid-template-columns: 1fr; }
  .full-field { grid-column: 1; }
  .status-field { grid-column: 1; align-items: flex-start; flex-wrap: wrap; }
  .week-grid { grid-template-columns: 1fr; }
  .week-day { min-height: 0; }
  .app-footer { grid-template-columns: 1fr; }
  .absence-dialog { width: calc(100% - 14px); padding: 15px; border-radius: 17px; }
  .roster-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .student-toggle { grid-template-rows: 105px auto; }
  .student-toggle img { height: 105px; }
}
