/* ==========================================================================
   Developer — design systém (světlý + tmavý režim, akcenty), mobile-first
   ========================================================================== */

:root {
  --bg: #f5f7fb;
  --bg-grad-1: #eef2ff;
  --bg-grad-2: #fdf2f8;
  --surface: #ffffff;
  --surface-2: #f3f5f9;
  --surface-3: #eaeef5;
  --text: #0f1729;
  --muted: #5b6675;
  --faint: #8a94a6;
  --border: #e3e8ef;
  --border-strong: #cfd6e0;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 6px 18px rgba(16, 24, 40, .08);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, .14);
  --danger: #e5484d;
  --success: #12a150;
  --warn: #d97706;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;

  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-contrast: #ffffff;

  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  --tint: color-mix(in srgb, var(--accent) 10%, var(--surface));
  --tint-2: color-mix(in srgb, var(--accent) 18%, transparent);
  --nav-w: 224px;
}

html[data-theme="dark"] {
  --bg: #0a0c11;
  --bg-grad-1: #101425;
  --bg-grad-2: #1a1220;
  --surface: #14181f;
  --surface-2: #1a1f29;
  --surface-3: #222834;
  --text: #e9ecf2;
  --muted: #9aa4b4;
  --faint: #6f7a8c;
  --border: #262d39;
  --border-strong: #333c4b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
  --danger: #ff6b6b;
  --success: #3dd68c;
  --warn: #f5a524;
}

html[data-accent="blue"]    { --accent: #3b82f6; --accent-strong: #2563eb; }
html[data-accent="rose"]    { --accent: #f43f5e; --accent-strong: #e11d48; }
html[data-accent="violet"]  { --accent: #8b5cf6; --accent-strong: #7c3aed; }
html[data-accent="emerald"] { --accent: #10b981; --accent-strong: #059669; }
html[data-accent="amber"]   { --accent: #f59e0b; --accent-strong: #d97706; --accent-contrast: #1a1205; }
html[data-accent="slate"]   { --accent: #64748b; --accent-strong: #475569; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, var(--bg-grad-1) 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 110%, var(--bg-grad-2) 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.02em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-strong); }
::selection { background: var(--tint-2); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

.app { min-height: 100dvh; }

/* Buttons ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1rem; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-contrast); font-weight: 600; cursor: pointer;
  transition: transform .06s ease, filter .15s ease, background-color .2s ease, border-color .2s ease, opacity .2s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.subtle { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn.icon { padding: .5rem; border-radius: 10px; }
.btn.sm { padding: .4rem .7rem; font-size: .85rem; }
.btn.block { width: 100%; }

/* Inputs ------------------------------------------------------------------- */
.field { display: block; margin-bottom: .9rem; }
.field > span { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
.input, select.input, textarea.input {
  width: 100%; padding: .65rem .8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .3s ease;
}
textarea.input { resize: vertical; min-height: 72px; }
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

/* Error / toast ------------------------------------------------------------ */
.err { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  padding: .55rem .75rem; border-radius: var(--radius-sm); font-size: .87rem; margin-bottom: .75rem; }
.toasts { position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: .5rem; z-index: 80; width: max-content; max-width: 92vw; }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); padding: .55rem .9rem; border-radius: 999px; font-size: .87rem; }
.toast.ok { border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.toast.bad { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* Auth (login / setup) ----------------------------------------------------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card {
  width: min(94vw, 400px); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2rem; box-shadow: var(--shadow-lg); animation: rise .35s ease both;
}
.brandmark { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: var(--accent-contrast);
  box-shadow: var(--shadow-md); margin-bottom: 1rem; }
.auth-card h1 { font-size: 1.25rem; }
.auth-card .sub { color: var(--muted); font-size: .9rem; margin: .35rem 0 1.25rem; }
.auth-card .btn { width: 100%; margin-top: .5rem; }
.hint { color: var(--faint); font-size: .8rem; margin-top: 1rem; text-align: center; }

/* Shell -------------------------------------------------------------------- */
.shell { display: flex; min-height: 100dvh; }
.sidebar { display: none; }
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .6rem;
  padding: .6rem clamp(.9rem, 4vw, 1.6rem); backdrop-filter: saturate(160%) blur(10px);
  background: color-mix(in srgb, var(--surface) 82%, transparent); border-bottom: 1px solid var(--border);
}
.topbar .logo { display: flex; align-items: center; gap: .55rem; font-weight: 700; }
.topbar .logo .dot { width: 24px; height: 24px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--accent-strong)); }
.spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .65rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-size: .82rem; }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--tint-2); color: var(--accent-strong);
  display: grid; place-items: center; font-size: .72rem; font-weight: 700; }

.content { padding: clamp(1rem, 3vw, 1.6rem) clamp(.9rem, 4vw, 1.6rem) 6.5rem; flex: 1; width: min(1040px, 100%); margin: 0 auto; }

/* Segmented theme toggle --------------------------------------------------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: .28rem .5rem; border-radius: 999px; cursor: pointer; font-size: .8rem; display: inline-flex; align-items: center; gap: .3rem; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Sidebar (desktop) -------------------------------------------------------- */
@media (min-width: 900px) {
  .sidebar {
    display: flex; flex-direction: column; width: var(--nav-w); flex: none; gap: .25rem;
    padding: 1rem .8rem; border-right: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    position: sticky; top: 0; height: 100dvh;
  }
  .sidebar .brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; padding: .4rem .5rem 1rem; }
  .sidebar .brand .dot { width: 28px; height: 28px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-strong)); }
  .nav-item { display: flex; align-items: center; gap: .65rem; padding: .6rem .7rem; border-radius: 10px; cursor: pointer;
    color: var(--muted); border: 1px solid transparent; background: transparent; text-align: left; font-weight: 600; }
  .nav-item:hover { background: var(--surface-2); color: var(--text); }
  .nav-item.active { background: var(--tint); color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
  .nav-item svg { width: 18px; height: 18px; flex: none; }
  .content { padding-bottom: 2rem; }
  .tabbar { display: none !important; }
}

/* Bottom tab bar (mobile) -------------------------------------------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: space-around;
  gap: 2px; padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .35rem .1rem;
  border: 0; background: transparent; color: var(--faint); font-size: .68rem; font-weight: 600; cursor: pointer; border-radius: 10px; }
.tab.active { color: var(--accent-strong); }
.tab svg { width: 18px; height: 18px; }

/* Cards / layout ----------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card.pad { padding: 1.1rem; }
.section + .section { margin-top: 1rem; }
.page-title { display: flex; align-items: baseline; gap: .7rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-title h2 { font-size: 1.35rem; }
.page-title .count { color: var(--muted); font-size: .88rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }

/* Grids -------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 1rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
.stat .n { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: .82rem; }
.stat.todo { border-left: 4px solid var(--muted); }
.stat.progress { border-left: 4px solid var(--accent); }
.stat.done { border-left: 4px solid var(--success); }
.stat.total { border-left: 4px solid var(--border-strong); }

/* Composer ----------------------------------------------------------------- */
.composer { display: flex; gap: .55rem; padding: .6rem; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.composer .input { border-color: transparent; background: transparent; }
.composer .input:focus { box-shadow: none; }

/* Task / note rows --------------------------------------------------------- */
.list { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.row {
  display: flex; align-items: flex-start; gap: .75rem; padding: .8rem .9rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); animation: rise .2s ease both;
}
.row:hover { border-color: var(--border-strong); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; word-break: break-word; }
.row .desc { color: var(--muted); font-size: .88rem; margin-top: .15rem; white-space: pre-wrap; word-break: break-word; }
.row .meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; font-size: .75rem; }
.row .controls { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; flex: none; }
.row.done .title { color: var(--faint); text-decoration: line-through; }
.row.done { opacity: .75; }

.pill { display: inline-flex; align-items: center; gap: .25rem; padding: .12rem .5rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: .7rem; font-weight: 600; }
.pill.p-TODO { border-color: var(--border-strong); }
.pill.p-IN_PROGRESS { color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: var(--tint); }
.pill.p-DONE { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.pill.pri-HIGH { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.pill.pri-MEDIUM { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.pri-LOW { color: var(--muted); }

.check { appearance: none; width: 1.3rem; height: 1.3rem; border-radius: 8px; border: 1.5px solid var(--border-strong);
  cursor: pointer; display: grid; place-items: center; flex: none; background: var(--surface); margin-top: .15rem; transition: all .15s ease; }
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after { content: ""; width: .34rem; height: .6rem; border: 2px solid var(--accent-contrast);
  border-top: 0; border-left: 0; transform: rotate(45deg) translateY(-1px); }

.empty { text-align: center; color: var(--faint); padding: 2.2rem 1rem; }
.empty svg { width: 52px; height: 52px; opacity: .5; margin-bottom: .5rem; }

/* Form grid ---------------------------------------------------------------- */
.form-grid { display: grid; gap: .7rem; }
@media (min-width: 720px) { .form-grid.cols { grid-template-columns: repeat(4, 1fr); } }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; }

/* Chat --------------------------------------------------------------------- */
.chat-shell { display: flex; flex-direction: column; height: min(74dvh, 720px); }
.chat-head { display: flex; align-items: center; gap: .55rem; padding: .75rem .9rem; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface)); border-radius: var(--radius) var(--radius) 0 0; }
.chat-head .lock { color: var(--accent-strong); display: inline-flex; }
.messages { flex: 1; overflow-y: auto; padding: .9rem; display: flex; flex-direction: column; gap: .55rem; overscroll-behavior: contain; }
.bubble { max-width: 80%; padding: .55rem .8rem; border-radius: 16px; border: 1px solid var(--border);
  background: var(--surface-2); box-shadow: var(--shadow-sm); animation: rise .2s ease both; }
.bubble .meta { font-size: .68rem; color: var(--muted); margin-bottom: .15rem; }
.bubble .body { white-space: pre-wrap; word-break: break-word; }
.bubble.me { margin-left: auto; background: var(--accent); color: var(--accent-contrast); border-color: transparent; }
.bubble.me .meta { color: color-mix(in srgb, var(--accent-contrast) 75%, transparent); }
.chat-compose { display: flex; gap: .5rem; padding: .6rem; border-top: 1px solid var(--border); background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius); }

/* Full-height private chat (mobile keyboard safe) -------------------------- */
.private-wrap { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; }
.private-wrap .chat-shell { height: auto; flex: 1; border-radius: 0; border: 0; box-shadow: none; }
.private-wrap .chat-head { border-radius: 0; padding-top: calc(.7rem + env(safe-area-inset-top)); }
.private-wrap .chat-compose { padding-bottom: calc(.6rem + env(safe-area-inset-bottom)); }

/* Settings ----------------------------------------------------------------- */
.settings-grid { display: grid; gap: 1rem; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.setting-row .label { font-weight: 600; }
.setting-row .desc { color: var(--muted); font-size: .84rem; }
.swatches { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; box-shadow: var(--shadow-sm); }
.swatch[aria-pressed="true"] { border-color: var(--text); outline: 2px solid var(--surface); }
.theme-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; width: min(100%, 420px); }
.theme-card { cursor: pointer; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: .6rem; text-align: center; background: var(--surface-2); }
.theme-card[aria-pressed="true"] { border-color: var(--accent); background: var(--tint); }
.theme-card .prev { height: 42px; border-radius: 8px; margin-bottom: .4rem; border: 1px solid var(--border); }
.theme-card .prev.light { background: linear-gradient(180deg, #fff, #eef1f7); }
.theme-card .prev.dark { background: linear-gradient(180deg, #1a1f29, #0a0c11); }
.theme-card .prev.system { background: linear-gradient(90deg, #fff 50%, #0a0c11 50%); }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-width: 560px) {
  .topbar .logo span.full { display: none; }
  .bubble { max-width: 88%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
