:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f6f7f9);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111827);
  --muted: var(--tg-theme-hint-color, #6b7280);
  --line: rgba(120, 130, 150, 0.24);
  --primary: var(--tg-theme-button-color, #2563eb);
  --primary-text: var(--tg-theme-button-text-color, #ffffff);
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

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

.title-block h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.12;
}

.title-block p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin: 12px 0;
}

.grid {
  display: grid;
  gap: 10px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
}

.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
  text-align: center;
  font-weight: 700;
}

.button.ghost {
  background: transparent;
}

.button:active {
  transform: translateY(1px);
}

.section-row,
.room-row,
.assignment-row,
.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  text-align: left;
}

.section-row,
.room-row,
.assignment-row {
  cursor: pointer;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  display: block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.row-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status.done {
  color: var(--good);
  border-color: color-mix(in srgb, var(--good) 35%, transparent);
}

.status.progress {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}

.status.problem {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 35%, transparent);
}

.progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(120, 130, 150, 0.22);
  margin-top: 8px;
}

.progress span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  background: var(--primary);
}

.check-row {
  align-items: flex-start;
}

.check-row input {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.check-standard {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
}

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

.footer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.summary-list {
  display: grid;
  gap: 8px;
}

@media (max-width: 520px) {
  .grid.two,
  .footer-actions {
    grid-template-columns: 1fr;
  }

  .title-block h1 {
    font-size: 23px;
  }
}
