:root {
  --cream: #F4EFE6; --paper: #FFFFFF; --ink: #2B2B2B; --muted: #6B665E; --line: #E7DCC8;
  --accent: #E8622A; --accent-ink: #C94F1C; --accent-soft: #FBE3D6;
  --ok: #2F7A4F; --ok-soft: #DCEFE3; --warn: #A86A00; --warn-soft: #FBEFD3; --bad: #B3261E; --bad-soft: #F8DEDC;
  --radius: 14px; --serif: "Newsreader", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  --shadow: 0 1px 2px rgba(43,43,43,.06), 0 4px 16px rgba(43,43,43,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 16px/1.5 var(--sans); }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; line-height: 1.15; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--ink); background: var(--paper); cursor: pointer; text-decoration: none;
  font-weight: 500; white-space: nowrap; transition: transform .1s ease-out, background .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn.primary:hover { background: #b2451a; }
.btn.ghost { border-color: var(--line); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.icon-btn { width: 44px; height: 44px; border-radius: 999px; border: 0; background: transparent; cursor: pointer; font-size: 22px; line-height: 1; }
.icon-btn:hover { background: rgba(43,43,43,.06); }
.icon-btn:active { transform: scale(.94); }
.pill { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.pill:empty { display: none; }

/* prisijungimas */
.login { min-height: 100svh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 4px; font-size: 26px; }
.login-card label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.login-card input { height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--cream); color: var(--ink); }
.form-error { color: var(--bad); margin: 0; min-height: 1.2em; font-size: 14px; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--ink); color: var(--cream); font-family: var(--serif); font-size: 20px; position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); top: -2px; right: -2px; }

/* viršutinė juosta */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: rgba(244,239,230,.88); backdrop-filter: blur(16px) saturate(160%); -webkit-backdrop-filter: blur(16px) saturate(160%); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-size: 19px; min-width: 0; }
.brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 4px; margin: 0 auto; }
.tabs a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
.tabs a:hover { color: var(--ink); background: rgba(43,43,43,.05); }
.tabs a.active { background: var(--ink); color: var(--cream); }
.user-btn { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; }
.menu { position: absolute; right: 16px; top: 58px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid; min-width: 200px; transform-origin: top right; animation: pop .14s ease-out; }
.menu button { text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 8px; cursor: pointer; min-height: 44px; }
.menu button:hover { background: var(--cream); }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }

main { padding: 20px max(16px, env(safe-area-inset-right)) 96px max(16px, env(safe-area-inset-left)); max-width: 1400px; margin: 0 auto; outline: none; }
.view-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.view-head h2 { margin: 0 auto 0 0; font-size: 30px; }
.muted { color: var(--muted); }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* mobilios skiltys apačioje — nykščio zona */
@media (max-width: 760px) {
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; justify-content: space-around; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(244,239,230,.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
  .tabs a { flex: 1; justify-content: center; padding: 8px 4px; font-size: 14px; min-height: 48px; }
  .brand { margin-right: auto; }
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--cream); }
  .view-head h2 { font-size: 24px; width: 100%; }
}

/* failai */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 15px; margin: -6px 0 14px; }
.crumbs a { text-decoration: none; padding: 6px 8px; border-radius: 8px; color: var(--muted); }
.crumbs a:hover { background: rgba(43,43,43,.05); color: var(--ink); }
.crumbs a:last-child { color: var(--ink); font-weight: 600; }
.seg { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 0 14px; min-height: 36px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--ink); color: var(--cream); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.card { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; text-align: left; padding: 0; display: flex; flex-direction: column; transition: transform .1s ease-out, box-shadow .2s; }
.card:hover { box-shadow: var(--shadow); }
.card:active { transform: scale(.98); }
.thumb { width: 100%; aspect-ratio: 4 / 3; background: #EFE8DC; display: grid; place-items: center; overflow: hidden; position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.contain img { object-fit: contain; padding: 10px; }
.thumb iframe { position: absolute; top: 0; left: 0; width: 400%; height: 400%; transform: scale(.25); transform-origin: 0 0; border: 0; pointer-events: none; background: #fff; }
.thumb .ico { font-size: 40px; }
.thumb .ext { position: absolute; left: 8px; top: 8px; background: rgba(43,43,43,.82); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .04em; padding: 2px 7px; border-radius: 6px; text-transform: uppercase; }
.card-body { width: 100%; padding: 10px 12px 12px; display: grid; gap: 4px; }
.card-name { font-weight: 500; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted); }
.card.dir .thumb { aspect-ratio: auto; height: 84px; background: var(--cream); }
.badge { display: inline-flex; align-items: center; gap: 3px; }
.badge.new { color: var(--accent-ink); font-weight: 600; }
.dropzone { position: fixed; inset: 0; z-index: 60; background: rgba(232,98,42,.12); border: 3px dashed var(--accent); display: grid; place-items: center; font-family: var(--serif); font-size: 28px; pointer-events: none; }
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 0 0 14px; }
.progress div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* peržiūra */
.viewer { position: fixed; inset: 0; z-index: 50; background: var(--cream); display: flex; flex-direction: column; animation: fadein .15s ease-out; }
@keyframes fadein { from { opacity: 0; } }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); background: var(--paper); }
.viewer-title { min-width: 0; flex: 1; display: grid; }
.viewer-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-title span { font-size: 12px; color: var(--muted); }
.viewer-actions { display: flex; gap: 6px; align-items: center; }
.viewer-body { flex: 1; display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
.viewer-stage { min-height: 0; display: grid; place-items: center; overflow: auto; background: #EAE3D6; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-stage video { max-width: 100%; max-height: 100%; }
.viewer-stage .doc { width: 100%; height: 100%; overflow: auto; background: var(--paper); padding: 24px clamp(16px, 4vw, 48px); align-self: stretch; }
.viewer-stage .doc pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.viewer-stage .doc img { max-width: 100%; }
.viewer-stage .doc table { border-collapse: collapse; } .viewer-stage .doc td, .viewer-stage .doc th { border: 1px solid var(--line); padding: 4px 8px; }
.viewer-side { border-left: 1px solid var(--line); background: var(--paper); display: flex; flex-direction: column; min-height: 0; }
.reactions { display: flex; gap: 6px; padding: 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.react { min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--cream); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.react.on { border-color: var(--ink); background: var(--ink); color: var(--cream); }
.react:active { transform: scale(.96); }
.react-who { width: 100%; font-size: 12px; color: var(--muted); }
.comments { flex: 1; overflow: auto; padding: 12px; display: grid; gap: 12px; align-content: start; }
.comment { background: var(--cream); border-radius: 12px; padding: 10px 12px; }
.comment header { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.comment header strong { font-weight: 600; }
.comment header time { color: var(--muted); font-size: 12px; }
.comment header button { margin-left: auto; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12px; }
.comment p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: grid; gap: 8px; padding: 12px; border-top: 1px solid var(--line); padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.comment-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; resize: vertical; background: var(--cream); }
@media (max-width: 900px) {
  .viewer-body { grid-template-columns: 1fr; grid-template-rows: minmax(260px, 55svh) max-content; overflow: auto; }
  .viewer-side { border-left: 0; border-top: 1px solid var(--line); }
  .comments { overflow: visible; }
  .viewer-stage img, .viewer-stage video { max-height: 55svh; }
  .viewer-actions .btn { display: none; }
}

/* darbai */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-size: 14px; }
.chip.on { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.chip:active { transform: scale(.97); }
.search { height: 36px; border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; background: var(--paper); min-width: 160px; flex: 1; max-width: 280px; }
.newtask { display: grid; grid-template-columns: 1fr 170px 160px auto; gap: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 16px; }
.newtask input, .newtask select { height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--cream); min-width: 0; }
@media (max-width: 760px) { .newtask { grid-template-columns: 1fr 1fr; } .newtask input[name=title] { grid-column: 1 / -1; } .newtask .btn { grid-column: 1 / -1; } }
.tasks { display: grid; gap: 8px; }
.task { display: grid; grid-template-columns: 44px minmax(220px, 2fr) 150px 150px 130px 120px minmax(160px, 1.4fr) 36px; gap: 8px; align-items: start;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.task.head { background: none; border: 0; padding: 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.task input:not([type=checkbox]), .task select, .task textarea { width: 100%; min-height: 40px; border: 1px solid transparent; border-radius: 8px; padding: 8px 10px; background: transparent; }
.task input:hover, .task select:hover, .task textarea:hover { border-color: var(--line); }
.task input:focus, .task select:focus, .task textarea:focus { border-color: var(--ink); background: var(--cream); outline: none; }
.task textarea { resize: vertical; min-height: 40px; line-height: 1.35; font-size: 15px; }
.task .title-in { font-weight: 500; }
.task.done { opacity: .6; } .task.done .title-in { text-decoration: line-through; }
.task.overdue { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.task.soon { box-shadow: inset 4px 0 0 var(--warn); }
.check { width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--ok); cursor: pointer; }
.st-laukia { color: var(--muted); } .st-daroma { color: #1F5FA8; font-weight: 600; } .st-blokuota { color: var(--bad); font-weight: 600; } .st-padaryta { color: var(--ok); font-weight: 600; }
.pr-aukštas { color: var(--accent-ink); font-weight: 600; }
.task-meta { grid-column: 2 / -1; font-size: 12px; color: var(--muted); padding: 0 10px; }
.del { width: 36px; height: 40px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 8px; font-size: 18px; }
.del:hover { background: var(--bad-soft); color: var(--bad); }
.duehint { font-size: 12px; padding: 0 10px; }
.duehint.bad { color: var(--bad); font-weight: 600; } .duehint.warn { color: var(--warn); font-weight: 600; }
@media (max-width: 1100px) {
  .task.head { display: none; }
  .task { grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr) 36px; }
  .task select, .task input[type=date] { min-width: 0; border-color: var(--line) !important; }
  .task .c-title { grid-column: 2 / 4; }
  .task .c-del { grid-column: 4; grid-row: 1; }
  .task .c-who, .task .c-due, .task .c-status, .task .c-prio { grid-column: auto; }
  .task .c-who { grid-column: 2; } .task .c-due { grid-column: 3; } .task .c-status { grid-column: 2; } .task .c-prio { grid-column: 3; }
  .task .c-notes { grid-column: 2 / 4; }
  .task-meta { grid-column: 2 / 4; }
  .task label.mini { display: block; font-size: 11px; color: var(--muted); padding: 0 10px; text-transform: uppercase; letter-spacing: .04em; }
}
.task label.mini { display: none; }
@media (max-width: 1100px) { .task label.mini { display: block; } }

/* lentelės */
.sheet-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.sheet-wrap { overflow: auto; max-height: calc(100svh - 230px); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); -webkit-overflow-scrolling: touch; }
table.sheet { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 14px; }
.sheet th { position: sticky; top: 0; z-index: 2; background: #FAF6EF; text-align: left; font-weight: 600; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; }
.sheet th button { width: 100%; text-align: left; border: 0; background: none; padding: 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 6px; min-height: 42px; }
.sheet th button small { color: var(--muted); font-weight: 400; }
.sheet td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; vertical-align: top; position: relative; }
.sheet td input, .sheet td textarea { width: 100%; border: 0; padding: 10px; min-height: 42px; background: transparent; font-size: 15px; }
.sheet td textarea { resize: vertical; display: block; line-height: 1.35; }
.sheet td input:focus, .sheet td textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #FFFBF5; }
.sheet .rownum { position: sticky; left: 0; z-index: 1; background: #FAF6EF; color: var(--muted); font-size: 12px; text-align: center; width: 44px; min-width: 44px; }
.sheet th.rownum { z-index: 3; }
.sheet .rownum button { border: 0; background: none; color: var(--muted); cursor: pointer; width: 100%; min-height: 42px; }
.sheet .rownum button:hover { color: var(--bad); }
.sheet .open-link { position: absolute; right: 4px; top: 8px; text-decoration: none; background: var(--accent-soft); border-radius: 6px; padding: 2px 6px; font-size: 12px; }
.sheet tr.saving td { background: #FFFBF5; }
.colmenu { position: fixed; z-index: 40; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 12px; display: grid; gap: 8px; width: 260px; animation: pop .14s ease-out; }
.colmenu input, .colmenu select { height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--cream); width: 100%; }
.colmenu .row { display: flex; gap: 6px; }

/* veikla */
.feed { display: grid; gap: 2px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.feed-item { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--cream); font-size: 13px; font-weight: 600; }
.feed-item a { color: var(--accent-ink); }
.feed-item time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.day-sep { padding: 8px 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #FAF6EF; }

.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--cream); padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 70; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast button { margin-left: 10px; background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.ctxmenu { position: fixed; z-index: 45; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid; min-width: 230px; animation: pop .12s ease-out; }
.ctxmenu button { text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 8px; cursor: pointer; min-height: 40px; font-size: 15px; }
.ctxmenu button:hover, .ctxmenu button:focus-visible { background: var(--cream); outline: none; }
.ctxmenu button.danger { color: var(--bad); }
.ctxmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
