:root {
    --bg: #f7f4ef;
    --surface: #ffffff;
    --ink: #202124;
    --muted: #666f7a;
    --line: #ded8ce;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --danger: #b42318;
    --shadow: 0 14px 40px rgba(33, 37, 41, 0.12);
  }

  * {
    box-sizing: border-box;
  }

  body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
  }

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

  button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
  }

  button:hover {
    background: var(--accent-dark);
  }

  button.ghost {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink);
  }

  input,
  textarea,
  select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 11px 12px;
  }

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

  label span {
    display: block;
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
  }

  .hidden {
    display: none !important;
  }

  .login-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
  }

  .login-panel {
    width: min(100%, 420px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
  }

  .login-panel h1,
  .topbar h1 {
    margin: 0;
    font-size: 28px;
  }

  .eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .stack {
    display: grid;
    gap: 14px;
    margin-top: 24px;
  }

  .message,
  .toast {
    color: var(--danger);
    min-height: 22px;
  }

  .main-view {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 16px;
  }

  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 0 14px;
  }

  .nav button {
    min-width: max-content;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
  }

  .nav button.active {
    background: var(--accent);
    color: #fff;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 4px 0 16px;
  }

  .tabs button {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
  }

  .tabs button.active {
    background: var(--accent);
    color: #fff;
  }

  .screen,
  .summary {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
  }

  .screen h2 {
    margin: 0 0 10px;
    font-size: 18px;
  }

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

  .home-foldout {
    margin: 12px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf9;
    padding: 12px;
  }

  .home-foldout h2 {
    margin: 0 0 10px;
    font-size: 1rem;
    font-weight: 800;
  }

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

  .home-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
  }

  .home-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf9;
    padding: 12px;
  }

  .form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 18px;
  }

  .form-grid > button {
    justify-self: start;
    min-width: 120px;
  }

  .inline-manager {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf9;
  }

  .wide {
    grid-column: 1 / -1;
  }

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

  .item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fffdf9;
  }

  .item h3 {
    margin: 0 0 6px;
    font-size: 16px;
  }

  .group-title {
    margin: 18px 0 2px;
    color: var(--accent-dark);
    font-size: 15px;
    font-weight: 800;
  }

  .material {
    color: var(--ink) !important;
    font-weight: 700;
    white-space: pre-wrap;
  }

  .material-editor {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fffdf9;
  }

  .material-editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
  }

  .material-editor-head h3 {
    margin: 0;
    font-size: 15px;
  }

  .material-rows {
    display: grid;
    gap: 10px;
  }

  .material-row {
    display: grid;
    grid-template-columns: 1fr 120px auto;
    gap: 8px;
    align-items: end;
  }

  .item p {
    margin: 4px 0;
    color: var(--muted);
  }

  .item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
  }

  .craft-skill-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf9;
    overflow: hidden;
  }

  .craft-skill-group + .craft-skill-group {
    margin-top: 10px;
  }

  .craft-skill-group summary {
    cursor: pointer;
    padding: 12px;
    font-weight: 800;
    background: #f7f2ea;
  }

  .craft-skill-list {
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  .craft-plan {
    display: grid;
    grid-template-columns: minmax(120px, 180px) 1fr;
    gap: 10px;
    align-items: end;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }

  .craft-plan input {
    min-height: 44px;
  }

  .summary-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf9;
    padding: 14px;
  }

  .craft-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 16px;
    align-items: start;
  }

  .summary-sticky {
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 24px);
    overflow: auto;
  }

  .summary-panel h2 {
    margin: 0 0 10px;
  }

  .summary-panel ul {
    margin: 0;
    padding-left: 20px;
  }

  .summary-panel li {
    margin: 6px 0;
    font-weight: 700;
  }

  .toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
    margin-bottom: 14px;
  }

  .calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(34px, 1fr));
    gap: 6px;
    margin-bottom: 18px;
  }

  .calendar-weekday,
  .calendar-empty {
    min-height: 24px;
  }

  .calendar-weekday {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
  }

  .screen-note {
    margin: -4px 0 14px;
    color: var(--muted);
    font-weight: 700;
  }

  .day-cell {
    position: relative;
    aspect-ratio: 1;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    display: grid;
    place-items: center;
    padding: 4px;
    cursor: pointer;
    min-height: 36px;
  }

  .day-cell.unavailable {
    border-color: #dc2626;
    background: #fff1f1;
    color: #991b1b;
  }

  .day-number {
    margin-top: -4px;
    font-weight: 800;
    font-size: 0.9rem;
  }

  .day-mark {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: clamp(22px, 6vw, 34px);
    font-weight: 900;
    line-height: 1;
    color: #dc2626;
    pointer-events: none;
  }

  .child-screen {
    position: fixed;
    top: 64px;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translateX(-50%);
    width: min(760px, calc(100% - 24px));
    max-height: calc(100vh - 88px);
    z-index: 30;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow);
  }

  .child-screen .screen-actions {
    margin-bottom: 8px;
  }

  .child-screen .screen-actions h2 {
    margin: 0;
    font-size: 1rem;
  }

  .child-screen .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
  }

  .child-screen .form-grid label span {
    font-size: 0.8rem;
  }

  .child-screen input,
  .child-screen select,
  .child-screen textarea {
    padding: 9px 10px;
  }

  .child-screen textarea {
    min-height: 72px;
  }

  .child-screen .list {
    max-height: 260px;
    overflow: auto;
  }

  .child-close {
    margin-left: auto;
    margin-bottom: 8px;
    z-index: 1;
    padding: 8px 12px;
  }

  .availability-table {
    min-width: 680px;
    display: grid;
    gap: 4px;
  }

  .availability-row {
    display: grid;
    grid-template-columns: 86px repeat(var(--user-count, 4), minmax(112px, 1fr));
    gap: 4px;
  }

  .availability-head .availability-cell {
    background: #f1ede5;
    font-weight: 800;
  }

  .availability-cell {
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 9px;
  }

  .availability-cell input {
    width: auto;
    margin-right: 6px;
  }

  .availability-cell.my-column {
    border-color: var(--accent);
    background: #eefaf7;
    box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.3);
  }

  .toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    max-width: calc(100% - 32px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 12px 14px;
    color: var(--ink);
  }

  .scroll-top {
    position: fixed;
    right: 16px;
    bottom: 76px;
    min-height: 42px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    box-shadow: var(--shadow);
  }

  .modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(32, 33, 36, 0.45);
  }

  .modal-panel {
    width: min(720px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 16px;
  }

  @media (max-width: 720px) {
    .main-view {
      padding: 12px;
    }

    .topbar {
      align-items: flex-start;
    }

    .screen-actions {
      align-items: stretch;
      flex-direction: column;
    }

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

    .inline-manager {
      grid-template-columns: 1fr;
    }

    .craft-plan {
      grid-template-columns: 1fr;
    }

    .craft-layout {
      grid-template-columns: 1fr;
    }

    .summary-sticky {
      position: fixed;
      left: 12px;
      right: 12px;
      bottom: 12px;
      z-index: 2;
      max-height: 40vh;
      overflow: auto;
      box-shadow: var(--shadow);
    }

    .material-editor-head,
    .material-row {
      align-items: stretch;
      grid-template-columns: 1fr;
      flex-direction: column;
    }

    .calendar {
      margin: 0 -2px;
    }

    .tabs {
      grid-template-columns: 1fr;
    }

    .home-grid {
      grid-template-columns: 1fr;
    }

    .scroll-top {
      right: 12px;
      bottom: 70px;
    }
  }