:root {
  color-scheme: light;
  --paper: #fbf7f0;
  --surface: #fffdf9;
  --ink: #342f2b;
  --muted: #776f68;
  --line: #e9ded2;
  --accent: #bc5938;
  --accent-dark: #8f3f27;
  --accent-soft: #f4ddd3;
  --blue: #dceaf0;
  --green: #dfead9;
  --sand: #efe4cb;
  --danger: #9b4336;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f1e9df;
  color: var(--ink);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-width: 320px; }
button, input, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid #d28a6f; outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }

#app {
  width: min(100%, 520px); min-height: 100dvh; margin: 0 auto; background: var(--paper);
  box-shadow: 0 18px 70px #513b2b14;
}
.shell { min-height: 100dvh; padding: calc(24px + env(safe-area-inset-top)) 22px calc(32px + env(safe-area-inset-bottom)); }
.narrow { max-width: 420px; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 27px; }
.brand { font-weight: 790; font-size: 25px; letter-spacing: 3.5px; }
.brand-sub { margin-top: 3px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: 2.3px; }
.profile-button, .icon-button {
  border: 1px solid var(--line); background: var(--surface); min-height: 44px; border-radius: 14px; padding: 9px 12px;
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px;
}
.profile-button .mini-avatar { width: 25px; height: 25px; border-radius: 9px; background: var(--accent-soft); display: grid; place-items: center; font-weight: 700; color: var(--accent-dark); }

.eyebrow { color: var(--accent); font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; font-weight: 750; margin-bottom: 8px; }
h1 { font-size: 29px; letter-spacing: -.9px; line-height: 1.14; font-weight: 720; }
h2 { font-size: 18px; letter-spacing: -.25px; }
.lead { color: var(--muted); line-height: 1.55; font-size: 14px; margin-top: 10px; }
.page-heading { margin-bottom: 22px; }

.prototype-note { margin: 18px 0; padding: 13px 14px; border-radius: 14px; background: #f7e8bf; color: #745a19; font-size: 12px; line-height: 1.5; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; }
.form-field { display: block; margin-bottom: 17px; }
.form-field > span, .fieldset legend { display: block; font-size: 13px; font-weight: 650; margin-bottom: 8px; }
.form-field input, .form-field textarea, .form-field select {
  width: 100%; min-height: 48px; border: 1px solid #dfd2c6; background: white; border-radius: 12px; padding: 12px 13px; color: var(--ink); font-size: 16px;
}
.form-field textarea { min-height: 92px; resize: vertical; }
.hint { margin-top: 7px; font-size: 12px; line-height: 1.45; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.fieldset { margin: 0 0 17px; padding: 0; border: 0; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.check-option, .radio-option { min-height: 47px; border: 1px solid var(--line); border-radius: 12px; padding: 11px; display: flex; align-items: center; gap: 9px; background: white; font-size: 14px; }
.radio-stack { display: grid; gap: 8px; }
.radio-option input, .check-option input { width: 18px; height: 18px; accent-color: var(--accent); }

.button { min-height: 48px; border: 0; border-radius: 14px; padding: 12px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 680; font-size: 14px; text-decoration: none; }
.button.primary { color: white; background: var(--accent); }
.button.secondary { border: 1px solid var(--line); background: var(--surface); }
.button.soft { background: var(--accent-soft); color: var(--accent-dark); }
.button.danger { background: #f4dfda; color: var(--danger); }
.button.text { background: transparent; color: var(--muted); font-weight: 550; }
.button.full { width: 100%; }
.button.small { min-height: 40px; padding: 9px 12px; font-size: 12px; }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.actions > * { flex: 1; }
.back-button { border: 0; background: transparent; color: var(--muted); padding: 0; min-height: 42px; display: inline-flex; gap: 7px; align-items: center; font-size: 13px; }

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 23px; }
.profile-card { min-height: 132px; border: 1px solid transparent; border-radius: 19px; padding: 18px; text-align: left; display: flex; flex-direction: column; justify-content: space-between; }
.profile-card:hover { border-color: #bba491; transform: translateY(-1px); }
.profile-card .avatar { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: #ffffff9c; font-weight: 750; }
.profile-card strong { font-size: 17px; }
.tone-clay { background: #efd8cf; color: #7e3f2b; }
.tone-sand { background: var(--sand); color: #715d31; }
.tone-blue { background: var(--blue); color: #3f6574; }
.tone-green { background: var(--green); color: #4c6844; }
.pin-box { margin-top: 22px; }
.pin-input { text-align: center; font-size: 26px!important; letter-spacing: 12px; padding-left: 24px!important; }
.person-focus { display: flex; align-items: center; gap: 14px; margin: 21px 0; }
.person-focus .avatar { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-weight: 760; }
.person-focus strong { display: block; font-size: 18px; }
.person-focus span { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }

.quick-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; margin-bottom: 8px; }
.segmented { display: flex; background: #eee5db; padding: 4px; border-radius: 13px; }
.segmented button { flex: 1; min-height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; }
.segmented button.active { color: var(--ink); background: var(--surface); box-shadow: 0 2px 8px #4d38240d; font-weight: 680; }
.new-button { width: 50px; padding: 0; font-size: 24px; }
.refresh-button { width: 48px; padding: 0; font-size: 22px; }
.sync-note { min-height: 18px; margin: 0 2px 12px; color: var(--muted); font-size: 11px; text-align: right; }
.recent-link { width: 100%; margin-bottom: 22px; border: 1px solid var(--line); background: var(--surface); border-radius: 15px; padding: 14px; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.recent-link strong { color: var(--ink); display: block; margin-bottom: 3px; font-size: 14px; }
.count { background: var(--accent-soft); color: var(--accent-dark); border-radius: 999px; padding: 5px 9px; font-weight: 720; }

.task-group { margin-bottom: 22px; }
.group-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 3px; margin-bottom: 9px; }
.group-heading h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.group-heading span { color: #968d84; font-size: 12px; }
.task-list { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--surface); }
.task-card { width: 100%; border: 0; background: transparent; padding: 16px; text-align: left; min-height: 82px; display: flex; gap: 12px; align-items: flex-start; }
.task-card + .task-card { border-top: 1px solid #eee6dd; }
.task-main { min-width: 0; flex: 1; }
.task-title { font-size: 15px; font-weight: 650; line-height: 1.35; }
.task-meta { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; display: flex; flex-wrap: wrap; gap: 5px 8px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: #cabeb1; flex: 0 0 auto; }
.status-dot.in_progress { background: var(--accent); }
.private-pill { color: #76588c; background: #eee5f5; padding: 2px 6px; border-radius: 6px; }
.empty { border: 1px dashed #d8cabd; border-radius: 17px; padding: 26px 18px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.5; }

.detail-card { background: var(--surface); border: 1px solid var(--line); border-radius: 19px; padding: 18px; margin-bottom: 14px; }
.detail-title { font-size: 24px; line-height: 1.2; letter-spacing: -.5px; overflow-wrap: anywhere; }
.detail-description { margin-top: 13px; color: var(--muted); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-meta { display: grid; gap: 12px; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.meta-row { display: flex; justify-content: space-between; gap: 15px; font-size: 13px; }
.meta-row span:first-child { color: var(--muted); }
.meta-row strong { text-align: right; }
.status-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.status-choice { min-height: 45px; border: 1px solid var(--line); border-radius: 12px; background: white; font-size: 13px; }
.status-choice.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; }
.section-title { margin: 24px 0 10px; font-size: 15px; }
.comment-list { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; overflow: hidden; }
.comment { padding: 14px 15px; }
.comment + .comment { border-top: 1px solid #eee5db; }
.comment-head { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; color: var(--muted); }
.comment-head strong { color: var(--ink); }
.comment p { margin-top: 7px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input { min-width: 0; flex: 1; border: 1px solid #dfd2c6; border-radius: 12px; padding: 11px; font-size: 16px; }
.comment-form button { flex: 0 0 auto; }

.recent-list { border: 1px solid var(--line); background: var(--surface); border-radius: 18px; overflow: hidden; }
.recent-item { padding: 16px; }
.recent-item + .recent-item { border-top: 1px solid #eee5db; }
.recent-item strong { font-size: 14px; display: block; line-height: 1.4; }
.recent-item p { color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.45; }

.toast { position: fixed; left: 50%; bottom: 20px; z-index: 30; transform: translate(-50%, 18px); opacity: 0; pointer-events: none; transition: .18s ease; background: #332d29; color: white; border-radius: 13px; padding: 12px 16px; max-width: calc(100% - 28px); text-align: center; font-size: 13px; box-shadow: 0 8px 35px #33261f33; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
dialog { width: min(400px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: 21px; padding: 21px; color: var(--ink); background: var(--paper); box-shadow: 0 18px 70px #2e211b33; }
dialog::backdrop { background: #342b2660; backdrop-filter: blur(2px); }
dialog h2 { margin-bottom: 9px; }
dialog p { color: var(--muted); font-size: 13px; line-height: 1.5; }

.loading-card { min-height: 300px; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.error-box { margin: 0 0 16px; border: 1px solid #e8c3ba; background: #f9e9e5; color: #7c352a; border-radius: 14px; padding: 12px 14px; font-size: 13px; line-height: 1.45; }
.form-message { min-height: 19px; margin: 8px 0; color: var(--danger); font-size: 12px; line-height: 1.45; }
.inline-action { display: block; margin-top: 8px; border: 0; border-radius: 9px; padding: 8px 10px; background: #f4dfda; color: var(--danger); font: inherit; font-weight: 680; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 560px) {
  #app { margin-top: 22px; margin-bottom: 32px; min-height: 780px; border-radius: 30px; overflow: clip; }
  .shell { min-height: 780px; padding: 28px; }
}
@media (max-width: 360px) {
  .shell { padding-left: 16px; padding-right: 16px; }
  .field-row, .profile-grid { gap: 8px; }
  .profile-card { min-height: 120px; padding: 15px; }
  h1 { font-size: 26px; }
  .actions { flex-direction: column; }
  .quick-row { gap: 7px; }
  .refresh-button { width: 44px; }
  .new-button { width: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto!important; transition: none!important; }
}
