/* ============================================================
   Flowcraft Flow — Apple-style design system
   ============================================================ */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Segoe UI", system-ui, "Helvetica Neue", sans-serif;

  /* Light */
  --bg: #f5f5f7;
  --bg-grad: radial-gradient(120% 120% at 80% -10%, #eef1f6 0%, #f5f5f7 45%, #f2f3f5 100%);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --surface-2: #f0f0f3;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #9a9aa0;
  --line: rgba(0, 0, 0, 0.08);
  --line-2: rgba(0, 0, 0, 0.05);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 12px 40px rgba(0,0,0,.10);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.16), 0 30px 90px rgba(0,0,0,.18);
  --glass-blur: saturate(180%) blur(22px);
  --brand-flow: #86868b;

  /* project colors */
  --c-blue:#0a84ff; --c-purple:#bf5af2; --c-green:#30d158; --c-orange:#ff9f0a;
  --c-red:#ff453a; --c-teal:#40c8e0; --c-pink:#ff375f; --c-indigo:#5e5ce6;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --ease: cubic-bezier(.32,.72,0,1);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"], :root.dark {
  --bg: #000000;
  --bg-grad: radial-gradient(120% 120% at 80% -10%, #16181d 0%, #0a0a0b 50%, #000 100%);
  --surface: rgba(28, 28, 30, 0.66);
  --surface-solid: #1c1c1e;
  --surface-2: #2c2c2e;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --line: rgba(255, 255, 255, 0.10);
  --line-2: rgba(255, 255, 255, 0.06);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 8px 30px rgba(0,0,0,.5);
  --shadow-lg: 0 20px 70px rgba(0,0,0,.7);
  --brand-flow: #8e8e93;
}
@media (prefers-color-scheme: dark) {
  body[data-theme="auto"] {
    --bg:#000; --bg-grad: radial-gradient(120% 120% at 80% -10%, #16181d 0%, #0a0a0b 50%, #000 100%);
    --surface: rgba(28,28,30,.66); --surface-solid:#1c1c1e; --surface-2:#2c2c2e;
    --text:#f5f5f7; --text-2:#a1a1a6; --text-3:#6e6e73;
    --line: rgba(255,255,255,.10); --line-2: rgba(255,255,255,.06);
    --accent:#0a84ff; --accent-soft: rgba(10,132,255,.18);
    --shadow-sm:0 1px 2px rgba(0,0,0,.4); --shadow-md:0 8px 30px rgba(0,0,0,.5); --shadow-lg:0 20px 70px rgba(0,0,0,.7);
    --brand-flow:#8e8e93;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  letter-spacing: -0.01em;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }

/* Brand wordmark — zweifarbig, KEIN grüner Punkt */
.brand { font-weight: 600; font-size: 21px; letter-spacing: -0.03em; user-select: none; }
.brand-flow { color: var(--brand-flow); }
.brand-craft { color: var(--text); }
.brand-lg { font-size: 38px; }

/* ============================ Login ============================ */
.login-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px; padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px; padding: 40px 32px; border-radius: var(--radius-lg);
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  box-shadow: var(--shadow-lg); animation: rise .6s var(--ease) both;
}
.login-tagline { color: var(--text-2); font-size: 15px; text-align: center; margin-top: -4px; }
#login-form { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.login-error { color: var(--c-red); font-size: 13px; min-height: 16px; text-align: center; }
.login-foot { color: var(--text-3); font-size: 12px; }

input[type=password], input[type=text], textarea {
  width: 100%; padding: 13px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid transparent; color: var(--text);
  font-size: 16px; outline: none; transition: border-color .2s, background .2s, box-shadow .2s;
}
input:focus, textarea:focus { border-color: var(--accent); background: var(--surface-solid); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea { resize: none; line-height: 1.45; }

.btn-primary {
  padding: 13px 20px; border-radius: var(--radius-sm); background: var(--accent);
  color: #fff; font-size: 16px; font-weight: 590; transition: transform .15s var(--ease), filter .2s, opacity .2s;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .5; pointer-events: none; }
.ghost-btn { color: var(--text-2); padding: 8px; border-radius: 10px; font-size: 18px; transition: background .2s, color .2s; }
.ghost-btn:hover { background: var(--line-2); color: var(--text); }
.ghost-btn.lg { padding: 13px 18px; font-size: 16px; font-weight: 500; }

.glass {
  background: var(--surface);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
}

/* ============================ App layout ============================ */
.app { display: grid; grid-template-columns: 264px 1fr; height: 100%; }

.sidebar {
  display: flex; flex-direction: column; padding: 20px 14px 14px;
  border-right: 1px solid var(--line); border-radius: 0;
  background: var(--surface); height: 100%;
}
.sidebar-top { padding: 4px 10px 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 11px;
  font-size: 15px; font-weight: 500; color: var(--text); text-align: left; transition: background .18s;
}
.nav-item:hover { background: var(--line-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-ico { width: 22px; text-align: center; font-size: 16px; opacity: .85; }
.nav-label { flex: 1; }
.nav-count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; min-width: 16px; text-align: right; }
.nav-item.active .nav-count { color: var(--accent); }

.nav-section {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 12px 6px; font-size: 12px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .04em;
}
.nav-add { width: 22px; height: 22px; border-radius: 7px; color: var(--text-2); font-size: 17px; line-height: 1; transition: background .2s; }
.nav-add:hover { background: var(--line-2); color: var(--accent); }
.project-list { display: flex; flex-direction: column; gap: 1px; }
.project-item { display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 11px; font-size: 14.5px; transition: background .18s; }
.project-item:hover { background: var(--line-2); }
.project-item.active { background: var(--accent-soft); }
.project-item .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item .ring-mini { flex-shrink: 0; }

.sidebar-foot { display: flex; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line-2); }

/* ============================ Main ============================ */
.main { display: flex; flex-direction: column; height: 100%; overflow: hidden; position: relative; }
.main-header {
  display: flex; align-items: center; gap: 14px; padding: 26px 34px 18px;
}
.hamburger { display: none; font-size: 22px; color: var(--text); padding: 4px; }
.main-title-wrap { flex: 1; min-width: 0; }
.main-header h1 { font-size: 30px; font-weight: 680; letter-spacing: -0.03em; }
.view-sub { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.today-ring-slot { flex-shrink: 0; }

.list { flex: 1; overflow-y: auto; padding: 4px 34px calc(140px + var(--safe-b)); display: flex; flex-direction: column; gap: 9px; scroll-behavior: smooth; }
.list-group-label { font-size: 13px; font-weight: 600; color: var(--text-3); padding: 16px 4px 4px; text-transform: uppercase; letter-spacing: .03em; }

/* ============================ Item card ============================ */
.item {
  display: flex; align-items: flex-start; gap: 14px; padding: 15px 17px;
  background: var(--surface-solid); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); transition: transform .18s var(--ease), box-shadow .2s, opacity .3s;
  animation: rise .4s var(--ease) both; cursor: pointer; position: relative;
}
.item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.item:active { transform: scale(.992); }
.item.done { opacity: .55; }
.item.done .item-title { text-decoration: line-through; color: var(--text-2); }

.check {
  flex-shrink: 0; width: 23px; height: 23px; border-radius: 50%; margin-top: 1px;
  border: 2px solid var(--text-3); position: relative; transition: all .25s var(--ease);
}
.check:hover { border-color: var(--accent); transform: scale(1.1); }
.item.done .check { background: var(--accent); border-color: var(--accent); }
.check svg { position: absolute; inset: 0; width: 100%; height: 100%; stroke: #fff; stroke-width: 2.4;
  fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 18; stroke-dashoffset: 18; transition: stroke-dashoffset .3s var(--ease) .05s; }
.item.done .check svg { stroke-dashoffset: 0; }
.check.note-dot { border-radius: 7px; border-style: solid; }

.item-body { flex: 1; min-width: 0; }
.item-title { font-size: 15.5px; font-weight: 500; line-height: 1.34; word-break: break-word; }
.item-note { font-size: 13.5px; color: var(--text-2); margin-top: 3px; line-height: 1.4; white-space: pre-wrap; }
.item-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500;
  padding: 3px 9px; border-radius: 8px; background: var(--surface-2); color: var(--text-2);
}
.chip.due { }
.chip.due.overdue { background: rgba(255,69,58,.14); color: var(--c-red); }
.chip.due.today { background: var(--accent-soft); color: var(--accent); }
.chip.proj { font-weight: 590; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.prio-flag { font-size: 12px; font-weight: 700; }
.prio-1 { color: var(--c-red); } .prio-2 { color: var(--c-orange); } .prio-3 { color: var(--accent); }

/* ============================ Progress ring ============================ */
.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--line); fill: none; }
.ring .fill { fill: none; stroke-linecap: round; transition: stroke-dashoffset .9s var(--ease); }
.ring-label { position: absolute; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.ring-mini .ring-label { font-size: 0; }

.today-ring-slot .ring-label { font-size: 17px; }
.today-ring-slot .ring-sub { position:absolute; bottom: -2px; font-size: 9px; color: var(--text-3); }

/* ============================ Empty ============================ */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding-bottom: 120px; text-align: center; }
.empty-ring { margin-bottom: 10px; opacity: .9; }
#empty-text { font-size: 18px; font-weight: 600; }
.empty-hint { color: var(--text-2); font-size: 14px; max-width: 240px; }

/* ============================ Capture bar ============================ */
.capture-bar {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(26px + var(--safe-b)); display: flex; align-items: center; gap: 14px; z-index: 30;
}
.mic-btn {
  width: 68px; height: 68px; border-radius: 50%;
  background: linear-gradient(180deg, var(--accent), #0a5fc0);
  box-shadow: 0 8px 28px rgba(0,113,227,.45), 0 2px 6px rgba(0,0,0,.2);
  display: grid; place-items: center; transition: transform .2s var(--ease), box-shadow .3s;
  position: relative;
}
.mic-btn:hover { transform: scale(1.05); }
.mic-btn:active { transform: scale(.94); }
.mic-btn.recording { background: linear-gradient(180deg, #ff453a, #d70015); box-shadow: 0 8px 30px rgba(255,69,58,.5); }
.mic-btn.recording::after {
  content:""; position:absolute; inset:-6px; border-radius:50%; border:2px solid rgba(255,69,58,.5);
  animation: ripple 1.4s ease-out infinite;
}
.mic-ico { width: 30px; height: 30px; fill: #fff; stroke: #fff; }
.type-btn {
  width: 50px; height: 50px; border-radius: 50%; font-size: 20px; color: var(--text-2);
  background: var(--surface); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm); transition: transform .2s, color .2s;
}
.type-btn:hover { transform: scale(1.06); color: var(--text); }

/* ============================ Sheets ============================ */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.32);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .25s ease both;
}
@media (min-width: 720px) { .sheet-backdrop { align-items: center; } }
.sheet {
  width: 100%; max-width: 540px; border-radius: 28px 28px 0 0; padding: 14px 22px calc(26px + var(--safe-b));
  box-shadow: var(--shadow-lg); max-height: 88vh; overflow-y: auto; animation: slideup .42s var(--ease) both;
}
@media (min-width: 720px) { .sheet { border-radius: 28px; margin-bottom: 0; animation: rise .4s var(--ease) both; } }
.sheet-sm { max-width: 420px; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--text-3); opacity: .4; margin: 2px auto 16px; }
.sheet h2 { font-size: 21px; font-weight: 680; letter-spacing: -0.02em; margin-bottom: 14px; }

/* recording */
.rec-state { text-align: center; padding: 10px 0 4px; }
.rec-waves { display: flex; align-items: center; justify-content: center; gap: 6px; height: 56px; margin-bottom: 18px; }
.rec-waves i { width: 6px; height: 14px; border-radius: 3px; background: var(--accent); animation: wave 1s ease-in-out infinite; }
.rec-waves i:nth-child(2){animation-delay:.15s} .rec-waves i:nth-child(3){animation-delay:.3s}
.rec-waves i:nth-child(4){animation-delay:.45s} .rec-waves i:nth-child(5){animation-delay:.6s}
.rec-state.idle .rec-waves i { animation-play-state: paused; height: 8px; opacity: .4; }
.rec-transcript { font-size: 18px; line-height: 1.45; min-height: 60px; color: var(--text); padding: 0 6px; font-weight: 450; }
.rec-transcript.placeholder { color: var(--text-3); }
.rec-hint { font-size: 12.5px; color: var(--text-3); margin-top: 12px; }
.rec-actions { display: flex; gap: 10px; margin-top: 20px; }
.rec-actions .btn-primary, .rec-actions .ghost-btn { flex: 1; }
.type-state { padding-top: 6px; }

/* thinking */
.think-state { text-align: center; padding: 40px 0; color: var(--text-2); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); margin: 0 auto 16px; animation: spin .8s linear infinite; }

/* review */
.review-head { margin-bottom: 6px; }
.review-sub { color: var(--text-2); font-size: 14px; margin-top: -8px; }
.review-cards { display: flex; flex-direction: column; gap: 11px; margin: 14px 0 4px; }
.rcard {
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 13px 14px;
  border: 1px solid var(--line-2); animation: rise .35s var(--ease) both; position: relative;
}
.rcard.removing { animation: collapse .3s var(--ease) forwards; }
.rcard-top { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.seg { display: inline-flex; background: var(--surface-solid); border-radius: 9px; padding: 2px; gap: 2px; border: 1px solid var(--line-2); }
.seg button { font-size: 12.5px; font-weight: 560; padding: 4px 11px; border-radius: 7px; color: var(--text-2); transition: all .18s; }
.seg button.on { background: var(--accent); color: #fff; }
.rcard-del { margin-left: auto; color: var(--text-3); font-size: 19px; padding: 2px 6px; border-radius: 7px; transition: color .2s, background .2s; }
.rcard-del:hover { color: var(--c-red); background: rgba(255,69,58,.1); }
.rcard-title { width: 100%; background: transparent; border: none; font-size: 15.5px; font-weight: 500; color: var(--text); padding: 2px 0; outline: none; }
.rcard-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.mini-field { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 4px 9px; border-radius: 8px; background: var(--surface-solid); border: 1px solid var(--line-2); color: var(--text-2); }
.mini-field select, .mini-field input { border: none; background: transparent; color: var(--text); font-size: 12.5px; outline: none; max-width: 130px; }
.review-actions, .review-actions { display: flex; gap: 10px; margin-top: 16px; }
.review-actions .btn-primary { flex: 2; } .review-actions .ghost-btn { flex: 1; }

/* detail */
.detail-body { padding: 4px 2px; display: flex; flex-direction: column; gap: 14px; }
.detail-title { font-size: 20px; font-weight: 640; line-height: 1.3; background: transparent; border: none; outline: none; color: var(--text); width: 100%; }
.detail-row { display: flex; gap: 10px; flex-wrap: wrap; }
.detail-note { width: 100%; min-height: 80px; border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); }
.detail-actions { display: flex; gap: 10px; margin-top: 4px; }
.danger-btn { color: var(--c-red); padding: 13px 18px; border-radius: var(--radius-sm); font-weight: 560; background: rgba(255,69,58,.1); transition: background .2s; }
.danger-btn:hover { background: rgba(255,69,58,.18); }

/* project colors picker */
.proj-colors { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.proj-colors button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; transition: transform .15s; }
.proj-colors button:hover { transform: scale(1.12); }
.proj-colors button.on { border-color: var(--text); transform: scale(1.12); }

/* ============================ Toast ============================ */
.toast {
  position: fixed; bottom: calc(110px + var(--safe-b)); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-solid); color: var(--text); padding: 12px 20px; border-radius: 13px;
  box-shadow: var(--shadow-md); font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: all .35s var(--ease); z-index: 200; border: 1px solid var(--line); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 300; }

/* ============================ Animations ============================ */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wave { 0%,100% { height: 12px; opacity:.6; } 50% { height: 38px; opacity: 1; } }
@keyframes ripple { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes collapse { to { opacity: 0; transform: scale(.9); height: 0; padding: 0; margin: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ============================ Responsive ============================ */
@media (max-width: 719px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 80%; max-width: 300px; z-index: 90;
    transform: translateX(-102%); transition: transform .4s var(--ease); border-radius: 0 22px 22px 0;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .hamburger { display: block; }
  .main-header { padding: 20px 20px 14px; padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
  .main-header h1 { font-size: 26px; }
  .list { padding: 4px 18px calc(150px + var(--safe-b)); }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 80; }
}
