/* Values follow design/style-tile.png. */
:root {
  --bg: #ffffff;
  --fg: #09090b;
  --primary: #18181b;
  --primary-fg: #fafafa;
  --muted: #f4f4f5;
  --muted-fg: #71717a;
  --border: #e4e4e7;
  --control-border: #8a8a93;
  --danger: #b91c1c;
  --radius: 8px;
  --radius-sm: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--primary);
  color: var(--primary-fg);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  z-index: 10;
}

.skip:focus {
  left: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

main:focus,
#flash:focus,
h1:focus {
  outline: none;
}

.ic {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Top bar and footer */
.topbar {
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

main {
  padding: 28px 0 48px;
}

.notice {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--muted);
  font-size: 14px;
  padding: 14px 0;
}

/* Type */
h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h2 {
  font-size: 19px;
  font-weight: 600;
}

.lead {
  color: var(--muted-fg);
  margin-top: 6px;
  max-width: 68ch;
}

.hint {
  color: var(--muted-fg);
  font-size: 14px;
  margin-top: 6px;
}

.mono {
  font-family: var(--mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted-fg);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.back:hover {
  color: var(--fg);
  text-decoration: underline;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn.primary {
  background: var(--primary);
  color: var(--primary-fg);
}

.btn.primary:hover {
  background: #3f3f46;
}

.btn.outline {
  background: var(--bg);
  border-color: var(--border);
  color: var(--fg);
}

.btn.ghost {
  background: transparent;
  color: var(--fg);
}

.btn.outline:hover,
.btn.ghost:hover {
  background: var(--muted);
}

.btn.iconbtn {
  width: 40px;
  padding: 0;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Status message */
.flash-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding: 10px 16px;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  background: #dcfce7;
  color: #166534;
  font-size: 14px;
  font-weight: 500;
}

.flash-box .btn {
  height: 32px;
  border-color: #166534;
  color: #166534;
  background: transparent;
}

/* Cards and lists */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.empty {
  text-align: center;
  padding: 40px 24px;
}

.empty p {
  color: var(--muted-fg);
  margin: 6px 0 18px;
}

.class-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
}

.class-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 24px;
  align-items: start;
}

.class-card .meta {
  color: var(--muted-fg);
  font-size: 14px;
  margin-top: 2px;
}

.class-card ul {
  grid-column: 1 / -1;
  list-style: none;
  margin: 8px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
  display: grid;
  gap: 4px;
}

.class-card li {
  display: flex;
  gap: 16px;
}

.class-card li .mono {
  color: var(--muted-fg);
  min-width: 13ch;
}

/* Calendar */
.cal-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.cal-bar h2 {
  min-width: 11ch;
  text-align: center;
}

.cal-bar .summary {
  margin-left: auto;
  color: var(--muted-fg);
  font-size: 14px;
}

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

.cal {
  table-layout: fixed;
  border: 1px solid var(--border);
}

.cal th {
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-fg);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.cal abbr {
  text-decoration: none;
}

.cal td {
  height: 104px;
  vertical-align: top;
  padding: 6px 8px;
  border: 1px solid var(--border);
}

.cal td.outside {
  background: var(--muted);
}

.daynum {
  display: inline-block;
  min-width: 24px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-fg);
}

.today .daynum {
  background: var(--primary);
  color: var(--primary-fg);
  border-radius: 999px;
  padding: 0 7px;
  text-align: center;
}

.cal ul {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.cal li {
  background: var(--muted);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.cal li b {
  font-weight: 600;
}

.cal li .mono {
  font-size: 11px;
  white-space: normal;
}

/* Events table */
.events {
  margin-top: 20px;
  border: 1px solid var(--border);
}

.events th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-fg);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.events td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 14px;
}

.events tr:last-child td {
  border-bottom: 0;
}

.ev-name {
  font-size: 16px;
  font-weight: 500;
}

.ev-desc {
  color: var(--muted-fg);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.row-actions {
  white-space: nowrap;
  text-align: right;
}

.row-actions .btn + .btn {
  margin-left: 6px;
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
}

/* Forms */
form {
  max-width: 720px;
}

.field {
  margin-top: 20px;
}

label,
legend {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
}

textarea {
  resize: vertical;
  font-family: var(--mono);
  font-size: 13px;
}

::placeholder {
  color: var(--muted-fg);
  opacity: 1;
}

[aria-invalid="true"] {
  border-color: var(--danger);
}

fieldset {
  margin: 24px 0 0;
  min-width: 0;
}

fieldset legend {
  float: left;
  width: 100%;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

fieldset .hint {
  clear: both;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.or {
  margin-top: 20px;
  color: var(--muted-fg);
  font-size: 14px;
}

.error {
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
  margin-top: 6px;
}

.error:empty {
  display: none;
}

.form-error {
  margin-top: 16px;
  padding: 10px 16px;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  background: #fee2e2;
  color: #991b1b;
  font-size: 14px;
  font-weight: 500;
}

.form-error:empty {
  display: none;
}

.form-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Edit modal */
dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  color: var(--fg);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

dialog form {
  padding: 20px 24px 24px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@media (max-width: 720px) {
  .grid2 {
    grid-template-columns: 1fr;
  }

  .cal td {
    height: 80px;
    padding: 4px;
  }
}
