html {
  color-scheme: light only;
  background: #F3F0EC;
}

:root {
  color-scheme: light only;
  /* Compass Color Palette - Warm Tech */
  --compass-amber: #E68A5C;
  --compass-teal: #5BA4A4;
  --compass-coral: #E07A5F;
  --compass-emerald: #4CAF7D;
  --compass-indigo: #6366F1;
  --compass-slate: #94A3B8;

  --bg-dark: #F3F0EC;
  --bg-card: #FFFFFF;
  --bg-surface: #FFFFFF;

  --text-primary: #1C1917;
  --text-secondary: #57534E;
  --text-muted: #8E8E93;

  --border-color: rgba(28, 25, 23, 0.08);
  --border-hover: rgba(28, 25, 23, 0.16);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 2px rgba(45, 35, 30, 0.04), 0 4px 12px rgba(45, 35, 30, 0.04);
  --shadow-md: 0 4px 16px rgba(45, 35, 30, 0.08);
  --shadow-lg: 0 12px 40px rgba(45, 35, 30, 0.14);

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-dark);
  background-image:
    radial-gradient(1200px 600px at 0% -10%, rgba(230, 138, 92, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(91, 164, 164, 0.10), transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* App shell */
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text-primary);
}

a {
  color: var(--compass-amber);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: #ff9d6d;
}

/* Layout */
#app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
#sidebar {
  width: 248px;
  background-color: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-normal);
  z-index: 100;
}

.logo-container {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--compass-amber);
  letter-spacing: 0.5px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.nav-menu {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.nav-item[hidden] {
  display: none !important;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.nav-item:hover {
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: rgba(230, 138, 92, 0.1);
  color: var(--compass-amber);
  font-weight: 500;
}

.nav-bottom {
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

/* Main Content */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
}

#topbar {
  height: 64px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  z-index: 10;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
}

.menu-toggle:hover {
  background: rgba(28, 25, 23, 0.06);
}

.sidebar-backdrop {
  display: none;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

#view-container {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 48px;
}

/* Page layout primitives */
.page {
  max-width: 1120px;
  margin: 0 auto;
  animation: fadeIn var(--transition-normal) forwards;
}

.page--wide {
  max-width: 1280px;
}

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

.page-header-copy {
  min-width: 0;
  flex: 1;
}

.page-header h1,
.page-header .page-heading {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.page-desc {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.45;
}

.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-block {
  margin-top: 24px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Components */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.glass-card,
.card.glass {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(28, 25, 23, 0.06);
}

.entity-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  cursor: pointer;
  position: relative;
}

.entity-card:hover {
  transform: translateY(-1px);
}

.entity-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.entity-card__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.entity-card__meta {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.entity-card__footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entity-card__actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.icon-btn:hover {
  background: rgba(28, 25, 23, 0.06);
  color: var(--compass-coral);
}

.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(28, 25, 23, 0.06);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--compass-amber);
  transition: width 0.35s ease;
}

.progress-fill--ok { background: var(--compass-emerald); }
.progress-fill--warn { background: var(--compass-amber); }
.progress-fill--bad { background: var(--compass-coral); }

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state,
.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 24px;
  color: var(--text-secondary);
}

.empty-state__icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.45;
  color: var(--compass-teal);
}

.empty-state__icon svg {
  width: 100%;
  height: 100%;
}

.empty-state h3,
.state-block h3 {
  margin: 0 0 8px;
  color: var(--text-primary);
  font-size: 1.05rem;
}

.empty-state p,
.state-block p {
  margin: 0;
  font-size: 14px;
  max-width: 320px;
}

.state-block--error {
  color: var(--compass-coral);
}

.state-block--error h3 {
  color: var(--compass-coral);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 680px;
  margin: 0 auto;
  padding-bottom: 4rem;
}

.form-stack .card,
.form-stack section.card {
  padding: 22px 24px;
}

.form-stack h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.form-stack > .card > p,
.form-field-hint {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 16px;
}

.create-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.create-actions .btn {
  flex: 1;
  min-width: 140px;
}

.create-actions .btn-primary {
  flex: 2;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-grid-deadline {
  grid-template-columns: 2fr 1fr;
}

.form-field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--text-secondary);
}

.form-field:last-child {
  margin-bottom: 0;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-primary);
  font: inherit;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: rgba(230, 138, 92, 0.55);
  box-shadow: 0 0 0 3px rgba(230, 138, 92, 0.12);
}

.form-field input:disabled {
  background: rgba(28, 25, 23, 0.04);
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 550;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  outline: none;
  gap: 8px;
}

.btn-primary {
  background-color: var(--compass-amber);
  color: #fff;
}

.btn-primary:hover {
  background-color: #de7d4d;
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background-color: rgba(28, 25, 23, 0.04);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: rgba(28, 25, 23, 0.08);
}

.btn-danger {
  background: rgba(224, 122, 95, 0.12);
  color: var(--compass-coral);
}

.btn-danger:hover {
  background: rgba(224, 122, 95, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--compass-teal);
  padding-left: 0;
  padding-right: 0;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-tier-reach { background: rgba(224, 122, 95, 0.15); color: var(--compass-coral); }
.badge-tier-match { background: rgba(91, 164, 164, 0.15); color: var(--compass-teal); }
.badge-tier-safety { background: rgba(76, 175, 125, 0.15); color: var(--compass-emerald); }

.badge-status-prep { background: rgba(148, 163, 184, 0.15); color: var(--compass-slate); }
.badge-status-submitted { background: rgba(99, 102, 241, 0.15); color: var(--compass-indigo); }
.badge-status-interview { background: rgba(230, 138, 92, 0.15); color: var(--compass-amber); }
.badge-status-wait { background: rgba(224, 122, 95, 0.15); color: var(--compass-coral); }
.badge-status-decided { background: rgba(76, 175, 125, 0.15); color: var(--compass-emerald); }

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 8px;
}

.dashboard-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-top: 24px;
}

@media (max-width: 900px) {
  .dashboard-split {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  display: flex;
  flex-direction: column;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
}

/* Kanban Board */
.kanban-board {
  display: flex;
  gap: 20px;
  height: 100%;
  overflow-x: auto;
  padding-bottom: 16px;
}

.kanban-column {
  flex: 0 0 300px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.kanban-column-header {
  padding: 16px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.kanban-cards {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: grab;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

/* iOS Form Style Modal — match iOS grouped list */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #F2F2F7;
  color: #000;
  border-radius: 16px;
  width: min(100%, 440px);
  max-height: min(92vh, 860px);
  box-shadow: 0 18px 50px rgba(28, 25, 23, 0.18);
  transform: scale(0.97);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 12px 14px;
  background: rgba(242, 242, 247, 0.92);
  backdrop-filter: blur(20px);
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  gap: 8px;
  border-bottom: 0.5px solid rgba(60, 60, 67, 0.18);
  z-index: 10;
  flex-shrink: 0;
}

#modal-title {
  text-align: center;
  color: #000;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal-header .btn-cancel,
.modal-header .btn-save {
  background: #fff;
  border: none;
  color: var(--compass-amber);
  font-size: 15px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: background var(--transition-fast), opacity var(--transition-fast);
}

.modal-header .btn-save {
  font-weight: 600;
  justify-self: end;
}

.modal-header .btn-cancel:hover,
.modal-header .btn-save:hover {
  background: #fafafa;
}

.modal-body {
  padding: 12px 16px 28px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  display: none;
}

/* iOS Form Components */
.ios-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Typography scale (iOS-like): header 13 / body 17 / footnote 13 */
.ios-type-picker {
  display: flex;
  justify-content: center;
  margin: 2px 0 16px;
}

.ios-type-picker select,
.ios-type-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23E68A5C' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right center;
  padding: 6px 20px 6px 8px;
  color: var(--compass-amber);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  outline: none;
  cursor: pointer;
  text-align: center;
}

.ios-type-select option {
  font-size: 17px;
  font-weight: 400;
  color: #000;
}

.ios-section {
  margin-bottom: 20px;
}

.ios-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--compass-teal); /* #5BA4A4 原青绿 */
  margin-bottom: 7px;
  padding: 0 4px 0 16px;
}

.ios-section-header .ios-section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  font-size: 13px;
  line-height: 1;
  color: inherit;
  filter: none;
}

.ios-group {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
}

.ios-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 11px 16px;
  min-height: 44px;
  position: relative;
}

.ios-row + .ios-row::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 0;
  top: 0;
  height: 0.5px;
  background: rgba(60, 60, 67, 0.18);
}

.ios-row-label {
  font-size: 17px;
  font-weight: 400;
  color: #000;
  flex-shrink: 0;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.ios-row-label--muted {
  color: #8E8E93;
  text-decoration: line-through;
}

.ios-input {
  border: none;
  background: transparent;
  font-size: 17px;
  font-weight: 400;
  color: #3C3C43;
  text-align: right;
  outline: none;
  flex: 1;
  min-width: 0;
  margin-left: 12px;
  font-family: inherit;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.ios-input::placeholder {
  color: #C7C7CC;
  font-size: 17px;
  font-weight: 400;
}

.ios-input[type="date"] {
  color-scheme: light;
  max-width: 168px;
  font-size: 17px;
}

.ios-textarea {
  width: 100%;
  border: none;
  padding: 12px 16px;
  min-height: 88px;
  font-size: 17px;
  font-weight: 400;
  outline: none;
  resize: vertical;
  background: transparent;
  color: #000;
  font-family: inherit;
  line-height: 1.4;
  letter-spacing: -0.02em;
}

.ios-textarea::placeholder {
  color: #C7C7CC;
  font-size: 17px;
}

.ios-check-row {
  cursor: pointer;
}

.ios-check-row .ios-row-label {
  flex: 1;
  min-width: 0;
}

.ios-check-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--compass-amber);
  flex-shrink: 0;
  margin: 0;
}

/* 总分/小分：避免嵌套 flex 里 .ios-input 的 flex:1 把宽度压成 0 */
.score-value-wrap {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: 16px;
  min-width: 96px;
  justify-content: flex-end;
}
.score-num-input.ios-input {
  flex: 0 0 auto;
  width: 72px;
  min-width: 72px;
  margin-left: 0;
  color: var(--compass-amber);
  font-variant-numeric: tabular-nums;
}
.score-total-input.ios-input {
  color: var(--compass-amber);
  font-weight: 600;
}
.score-max-hint {
  color: #8E8E93;
  font-size: 15px;
  margin-left: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}

.ib-subject-row {
  align-items: flex-start;
}
.ib-subject-fields {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: 1;
  min-width: 0;
  margin-left: 12px;
}
.ib-subject-name.ios-input {
  flex: 1;
  width: 100%;
  min-width: 140px;
  margin-left: 0;
  text-align: right;
}
@media (min-width: 520px) {
  .ib-subject-fields {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }
  .ib-subject-name.ios-input {
    max-width: 220px;
  }
}
.ios-select {
  border: none;
  background: transparent;
  font-size: 17px;
  color: var(--compass-amber);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  text-align: right;
  cursor: pointer;
  font-family: inherit;
  font-weight: 400;
  margin-left: auto;
  padding-right: 2px;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.ios-select option {
  font-size: 17px;
  font-weight: 400;
  color: #000;
}

.score-num-input.ios-input,
.score-total-input.ios-input {
  font-size: 17px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn var(--transition-normal) forwards;
}

@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .admin-secondary-grid {
    grid-template-columns: 1fr !important;
  }
  #view-container {
    padding: 20px 16px 40px;
  }
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  .page-header-actions {
    width: 100%;
  }
  .page-header-actions .btn {
    flex: 1;
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* —— Mobile shell (drawer nav); desktop unchanged above 768px —— */
@media (max-width: 768px) {
  body {
    background-attachment: scroll;
  }

  #app-container {
    height: 100dvh;
    width: 100%;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 180;
    background: rgba(28, 25, 23, 0.36);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open .sidebar-backdrop[hidden] {
    display: block;
  }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    max-width: 320px;
    background: #FFFFFF;
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    transition: transform var(--transition-normal);
    z-index: 200;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  body.sidebar-open #sidebar {
    transform: translateX(0);
  }

  #main-content {
    width: 100%;
    min-width: 0;
  }

  #topbar {
    height: calc(56px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 12px 0 6px;
    background: rgba(255, 255, 255, 0.92);
  }

  .page-title {
    font-size: 17px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions {
    gap: 8px;
    flex-shrink: 0;
  }

  .topbar-actions .btn {
    padding: 8px 12px;
    font-size: 14px;
  }

  #view-container {
    padding: 16px 14px calc(28px + env(safe-area-inset-bottom));
  }

  .logo-container {
    padding: 18px 16px 12px;
  }

  .nav-item {
    padding: 12px 12px;
    min-height: 44px;
  }

  .form-grid-2,
  .form-grid-deadline {
    grid-template-columns: 1fr;
  }

  .create-actions {
    flex-direction: column;
  }

  .create-actions .btn,
  .create-actions .btn-primary {
    flex: 1 1 auto;
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-value {
    font-size: 26px;
  }

  .kanban-board {
    gap: 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }

  .kanban-column {
    flex: 0 0 min(280px, 82vw);
    scroll-snap-align: start;
  }

  .modal-overlay {
    padding: 0;
    align-items: stretch;
  }

  .modal-content {
    width: 100%;
    max-width: none;
    max-height: none;
    height: 100%;
    border-radius: 0;
    transform: none;
  }

  .auth-screen {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    align-items: flex-start;
    padding-top: max(24px, env(safe-area-inset-top));
  }

  .auth-card {
    padding: 24px 18px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
  }

  .user-menu {
    margin: 8px 8px 4px;
    background: rgba(28, 25, 23, 0.04);
  }

  .page-header {
    gap: 10px;
  }

  .page-desc {
    font-size: 14px;
  }
}

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--compass-background, #f7f3ee); }
.auth-screen[hidden] { display: none; }
.auth-card { width: min(100%, 420px); padding: 32px; border-radius: 20px; background: var(--surface, #fff); box-shadow: 0 18px 50px rgba(45, 35, 30, .12); text-align: center; }
.auth-logo { width: 72px; height: 72px; border-radius: 16px; display: block; margin: 0 auto 16px; object-fit: cover; }
.auth-card h1 { margin: 0 0 8px; }
.auth-card p { color: var(--text-secondary); margin: 0 0 24px; }
.auth-card label { display: grid; gap: 7px; margin: 14px 0; font-size: 14px; text-align: left; }
.auth-card input { width: 100%; box-sizing: border-box; padding: 12px 14px; border: 1px solid rgba(100,80,65,.2); border-radius: 10px; background: transparent; color: inherit; }
.auth-card button { width: 100%; margin-top: 10px; }
.auth-switch { margin-top: 18px; border: 0; background: none; color: var(--compass-teal); cursor: pointer; }
.auth-error { color: var(--compass-coral); min-height: 20px; font-size: 14px; }

.user-menu { display: flex; align-items: center; gap: 10px; margin: 12px 14px; padding: 10px; border-radius: 10px; background: rgba(28, 25, 23, 0.04); color: var(--text-secondary); font-size: 13px; }
.user-menu .user-avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--compass-amber); color: #fff; font-weight: 700; }
.user-menu .user-copy { min-width: 0; flex: 1; }
.user-menu .user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.user-menu button { border: 0; background: none; color: var(--text-secondary); cursor: pointer; padding: 4px; }
