/* Shared component library. Every view builds from these classes;
   view-specific CSS lives in the views-*.css files. */

.ico { width: 16px; height: 16px; flex: none; stroke-width: 1.85; }
.ico-sm { width: 14px; height: 14px; }
.ico-lg { width: 20px; height: 20px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: var(--r-sm); font-weight: 500; font-size: 13.5px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  transition: background var(--dur) var(--ease), border-color var(--dur), box-shadow var(--dur), transform 80ms;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 1px 2px rgba(7,112,155,.3); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); background: var(--danger); }
.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-soft { background: var(--brand-soft); border-color: transparent; color: var(--brand-text); }
.btn-soft:hover { background: var(--brand-soft-2); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; gap: 5px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 15px; border-radius: var(--r-md); }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-block { width: 100%; }

/* ---------- Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--text); }
.hint { font-size: 12px; color: var(--text-3); }
.error-text { font-size: 12px; color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .ico { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.input-group > .input { padding-left: 32px; }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2385969c' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }

/* Switch */
.switch { position: relative; display: inline-flex; width: 34px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 20px; background: var(--line-strong); transition: background var(--dur); cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-ring); }

/* Selection checkbox (multi-select, settings) */
.cbx { appearance: none; width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--line-strong); background: var(--surface); display: inline-grid; place-content: center; cursor: pointer; flex: none; margin: 0; }
.cbx::after { content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform 120ms var(--ease); }
.cbx:checked { background: var(--brand); border-color: var(--brand); }
.cbx:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.radio { appearance: none; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-strong); cursor: pointer; margin: 0; flex: none; }
.radio:checked { border: 5px solid var(--brand); }

/* Completion control: the drop-shaped check from the logo mark.
   Markup comes from App.ui.dropCheck(); toggled with .is-done */
.drop-check { width: 18px; height: 18px; flex: none; color: var(--line-strong); cursor: pointer; border-radius: 50%; display: inline-grid; place-items: center; }
.drop-check svg { width: 18px; height: 18px; overflow: visible; }
.drop-check .dc-shape { fill: transparent; stroke: currentColor; stroke-width: 34; transition: fill 160ms var(--ease), stroke 160ms; }
.drop-check .dc-tick { fill: none; stroke: #fff; stroke-width: 58; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 420; stroke-dashoffset: 420; transition: stroke-dashoffset 260ms var(--ease) 60ms; }
.drop-check:hover { color: var(--brand); }
.drop-check:hover .dc-tick { stroke: var(--brand); stroke-dashoffset: 0; opacity: .35; }
.drop-check.is-done { color: var(--brand); }
.drop-check.is-done .dc-shape { fill: var(--brand); stroke: var(--brand); }
.drop-check.is-done .dc-tick { stroke: #fff; stroke-dashoffset: 0; opacity: 1; }
.drop-check.just-done { animation: drop-pop 360ms var(--ease); }
@keyframes drop-pop { 0% { transform: scale(1); } 40% { transform: scale(1.28) rotate(-6deg); } 100% { transform: scale(1); } }
.drop-check.prio-urgent { color: var(--p-urgent); } .drop-check.prio-high { color: var(--p-high); }

/* ---------- Chips, tags, badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border-radius: var(--r-xs); font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip .ico { width: 13px; height: 13px; }
.chip-overdue { background: var(--danger-soft); color: var(--danger); }
.chip-today { background: var(--warning-soft); color: var(--warning); }
.chip-done { background: var(--success-soft); color: var(--success); }
.chip-brand { background: var(--brand-soft); color: var(--brand-text); }
.tag { --c: var(--tag-slate); display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 500; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); white-space: nowrap; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; background: var(--brand); color: #fff; font-variant-numeric: tabular-nums; }
.badge-muted { background: var(--surface-3); color: var(--text-2); }
.role-pill { display: inline-flex; height: 22px; align-items: center; padding: 0 8px; border-radius: var(--r-pill); font-size: 12px; font-weight: 500; border: 1px solid var(--line); color: var(--text-2); }
.role-owner { color: #a16207; border-color: #f2d48a; background: #fdf6e3; }
.role-admin { color: var(--brand-text); border-color: var(--brand-soft-2); background: var(--brand-soft); }
.role-guest { color: var(--text-3); border-style: dashed; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.status-dot.ok { background: var(--success); } .status-dot.warn { background: var(--warning); } .status-dot.err { background: var(--danger); }

/* Priority glyph: 4 bars like signal strength, urgent is a filled square */
.prio { display: inline-flex; align-items: flex-end; gap: 1.5px; width: 14px; height: 12px; flex: none; }
.prio i { width: 3px; border-radius: 1px; background: var(--line-strong); }
.prio i:nth-child(1) { height: 5px; } .prio i:nth-child(2) { height: 8px; } .prio i:nth-child(3) { height: 12px; }
.prio-low i:nth-child(1) { background: var(--p-low); }
.prio-medium i:nth-child(-n+2) { background: var(--p-medium); }
.prio-high i { background: var(--p-high); }
.prio-urgent { width: 14px; height: 14px; border-radius: 3px; background: var(--p-urgent); color: #fff; font-size: 10px; font-weight: 800; display: inline-grid; place-items: center; align-items: center; }

/* ---------- Avatars ---------- */
.avatar { --av: var(--brand); width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-size: 10.5px; font-weight: 600; color: #fff; background: var(--av); letter-spacing: .02em; user-select: none; }
.avatar-xs { width: 18px; height: 18px; font-size: 8.5px; }
.avatar-sm { width: 20px; height: 20px; font-size: 9px; }
.avatar-md { width: 32px; height: 32px; font-size: 12.5px; }
.avatar-lg { width: 44px; height: 44px; font-size: 16px; }
.avatar-xl { width: 72px; height: 72px; font-size: 26px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }
.avatar-more { background: var(--surface-3); color: var(--text-2); }

/* ---------- Surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-pad { padding: 20px; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 18px; }
.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 4px; font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; font-family: var(--font); }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 48px 20px; color: var(--text-2); }
.empty .empty-ico { width: 48px; height: 48px; border-radius: 14px; background: var(--brand-soft); color: var(--brand-text); display: grid; place-items: center; }
.empty .empty-ico .ico { width: 22px; height: 22px; }
.empty h3 { color: var(--text); font-size: 15px; font-weight: 600; }
.empty p { max-width: 360px; font-size: 13px; }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width 300ms var(--ease); }
.progress.warn > i { background: var(--warning); } .progress.danger > i { background: var(--danger); }

/* Tabs & segmented control */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tab { height: 38px; padding: 0 12px; font-size: 13.5px; font-weight: 500; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--brand); }
.segmented { display: inline-flex; padding: 2px; border-radius: var(--r-md); background: var(--surface-3); gap: 2px; }
.segmented button { height: 28px; padding: 0 10px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--text-3); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }

/* ---------- Overlays (App.ui) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 24, 28, .42); z-index: 80; animation: fade-in 140ms var(--ease); }
@keyframes fade-in { from { opacity: 0; } }
.modal { position: fixed; left: 50%; top: 12vh; transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); max-height: 78vh; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3); z-index: 81; animation: modal-in 180ms var(--ease); border: 1px solid var(--line); }
.modal-lg { width: min(820px, calc(100vw - 32px)); }
.modal-sm { width: min(420px, calc(100vw - 32px)); }
@keyframes modal-in { from { opacity: 0; transform: translate(-50%, 8px) scale(.98); } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.modal-head h2 { font-size: 17px; font-weight: 600; flex: 1; }
.modal-body { padding: 10px 20px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); background: var(--surface); box-shadow: var(--shadow-3); z-index: 81; display: flex; flex-direction: column; animation: sheet-in 220ms var(--ease); border-left: 1px solid var(--line); }
@keyframes sheet-in { from { transform: translateX(32px); opacity: 0; } }
.menu { position: fixed; z-index: 90; min-width: 200px; max-width: 320px; max-height: 360px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-3); padding: 4px; animation: menu-in 120ms var(--ease); }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.menu-item { width: 100%; display: flex; align-items: center; gap: 9px; height: 32px; padding: 0 9px; border-radius: var(--r-sm); font-size: 13.5px; color: var(--text); text-align: left; }
.menu-item:hover, .menu-item.is-focused { background: var(--hover); }
.menu-item .ico { color: var(--text-2); }
.menu-item.is-selected { color: var(--brand-text); font-weight: 500; }
.menu-item.is-selected::after { content: ""; margin-left: auto; width: 8px; height: 5px; border: 2px solid var(--brand); border-top: 0; border-right: 0; transform: rotate(-45deg); }
.menu-item.danger, .menu-item.danger .ico { color: var(--danger); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 0; }
.menu-label { padding: 6px 9px 4px; font-size: 11.5px; font-weight: 500; color: var(--text-3); }
.menu-search { padding: 4px 4px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-search .input { height: 30px; border: 0; box-shadow: none; padding: 0 6px; }
.popover { position: fixed; z-index: 90; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-3); animation: menu-in 120ms var(--ease); }

/* Toasts */
.toast-stack { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 8px 8px 14px; border-radius: var(--r-md); background: #1f2b30; color: #eef4f6; box-shadow: var(--shadow-3); font-size: 13.5px; animation: toast-in 220ms var(--ease); max-width: calc(100vw - 32px); }
.toast .ico { color: #7fd3f3; }
.toast.is-error .ico { color: #ff8a8d; }
.toast.is-success .ico { color: #5fd3a8; }
.toast .toast-action { color: #7fd3f3; font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.toast .toast-action:hover { background: rgba(255,255,255,.08); }
.toast .toast-timer { width: 18px; height: 18px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.toast.is-leaving { animation: toast-out 160ms var(--ease) forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* Tooltip via [data-tip] */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  background: #1f2b30; color: #eef4f6; font-size: 11.5px; font-weight: 500; line-height: 1.3; padding: 5px 8px; border-radius: 6px;
  white-space: nowrap; z-index: 100; pointer-events: none; animation: fade-in 120ms 250ms both;
}
[data-tip-pos="bottom"]:hover::after { bottom: auto; top: calc(100% + 6px); }
[data-tip-pos="right"]:hover::after { left: calc(100% + 8px); bottom: auto; top: 50%; transform: translateY(-50%); }

/* Mini calendar + due picker (App.ui.miniCalendar / pickDue) */
.mini-cal { width: 252px; }
.mini-cal-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 8px; font-size: 13px; }
.mini-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.mini-cal-grid > span { font-size: 11px; color: var(--text-3); padding: 4px 0; }
.mini-cal-grid button { height: 32px; border-radius: var(--r-sm); font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text); }
.mini-cal-grid button:hover { background: var(--hover); }
.mini-cal-grid button.is-out { color: var(--text-3); }
.mini-cal-grid button.is-today { color: var(--brand-text); font-weight: 700; box-shadow: inset 0 0 0 1px var(--brand-soft-2); }
.mini-cal-grid button.is-selected { background: var(--brand); color: #fff; font-weight: 600; }
.due-picker { display: grid; grid-template-columns: 190px 268px; }
.due-quick { padding: 6px; border-right: 1px solid var(--line); }
.due-cal { padding: 10px 8px; }
.due-time { grid-column: 1 / -1; padding: 8px 12px; border-top: 1px solid var(--line); }
@media (max-width: 520px) { .due-picker { grid-template-columns: 1fr; } .due-quick { border-right: 0; border-bottom: 1px solid var(--line); } }

/* Rich text output (descriptions, comments) */
.prose { font-size: 14px; line-height: 1.65; color: var(--text); }
.prose p { margin: 0 0 8px; } .prose p:last-child { margin-bottom: 0; }
.prose ul, .prose ol { padding-left: 20px; margin: 0 0 8px; } .prose ul { list-style: disc; } .prose ol { list-style: decimal; }
.prose h1 { font-size: 20px; margin: 12px 0 6px; } .prose h2 { font-size: 17px; margin: 10px 0 6px; } .prose h3 { font-size: 15px; margin: 8px 0 4px; }
.prose blockquote { margin: 0 0 8px; padding: 2px 12px; border-left: 3px solid var(--brand); color: var(--text-2); }
.prose pre { background: var(--surface-3); border-radius: var(--r-sm); padding: 10px 12px; font-size: 12.5px; overflow-x: auto; }
.prose code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.prose .mention { color: var(--brand-text); background: var(--brand-soft); padding: 0 4px; border-radius: 4px; font-weight: 500; }
.prose .task-link { font-weight: 500; }
.prose table { border-collapse: collapse; margin: 0 0 8px; } .prose td, .prose th { border: 1px solid var(--line); padding: 5px 9px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
