/* Kostra appky. Barvy a písma bere z proměnných, které nastavuje themes.css. */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--bg, #FCF8F5);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#app { height: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  height: 100%;
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font-family: var(--f-body);
}

/* ---------- hlavička a záložky ---------- */
.app-head { padding-top: calc(env(safe-area-inset-top, 0px) + 10px); display: grid; gap: 10px; flex: none; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding-left: max(22px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
}
.brand { font-family: var(--f-label); font-size: 11px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 50%; flex: none; }
.icon-btn svg { width: 22px; height: 22px; }

.tabs {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 2px max(22px, env(safe-area-inset-right, 0px)) 6px max(22px, env(safe-area-inset-left, 0px));
  scroll-padding-inline: 22px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; white-space: nowrap; font-family: var(--f-label); min-height: 36px; }
.tab .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }

/* ---------- list úkolů ---------- */
.sheet {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-top: 18px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  padding-left: max(22px, env(safe-area-inset-left, 0px));
  padding-right: max(22px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column;
}
.date { font-family: var(--f-label); font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.title-row { display: flex; align-items: center; gap: 4px; }
.title { margin: 2px 0 0; font-family: var(--f-title); font-size: var(--title-size); font-weight: 400; line-height: 1.4; overflow-wrap: anywhere; min-width: 0; color: var(--title-color); }
.title-row .icon-btn { margin-right: -10px; margin-left: auto; }
.title-row .icon-btn svg { width: 19px; height: 19px; }
.count { font-family: var(--f-label); font-size: 12.5px; font-weight: 600; color: var(--muted); min-height: 18px; margin: 0 0 12px; }

.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--task-gap); }
.task { display: flex; align-items: flex-start; gap: 4px; font-size: var(--body-size); line-height: 1.3; }
.check {
  flex: none; width: 44px; height: 44px; margin: -10px 0 -10px -11px;
  display: grid; place-items: center; padding: 0; border: 0; background: transparent;
}
.check .box {
  width: 22px; height: 22px; display: grid; place-items: center;
  border: var(--box-border) solid var(--box-color); border-radius: var(--box-radius);
  color: var(--box-tick); transition: background-color .2s ease;
}
.check svg { width: 12px; height: 12px; opacity: 0; transition: opacity .2s ease; }
.task.done .check .box { background: var(--box-color); }
.task.done .check svg { opacity: 1; }
.task .text {
  flex: 1; min-width: 0; text-align: left; padding: 0; border: 0; background: transparent;
  font-family: var(--f-body); font-size: inherit; line-height: inherit; overflow-wrap: anywhere;
  transition: opacity .25s ease;
}
.task.done .text { opacity: var(--done-opacity); text-decoration: line-through; text-decoration-thickness: 1px; }

.empty { color: var(--muted); font-size: 16px; margin: 6px 0 4px; font-family: var(--f-label); }
.add { margin-top: 10px; }
.add input { width: 100%; border: 0; background: transparent; font-family: var(--f-body); font-size: max(16px, var(--body-size)); padding: 12px 0; color: var(--ink); }
.add input::placeholder { color: var(--muted); opacity: 1; }
.nudge { margin-top: 24px; align-self: flex-start; border: 0; background: transparent; padding: 8px 0; font-family: var(--f-label); font-size: 13.5px; color: var(--title-color); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- okna zespodu ---------- */
.sheet-layer { position: fixed; inset: 0; z-index: 10; font-family: var(--f-label); color: var(--ink); }
.backdrop { position: absolute; inset: 0; background: rgba(55, 40, 35, .32); animation: fade .2s ease; }
.bottom-sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 90%; overflow-y: auto; overscroll-behavior: contain;
  background: var(--sheet-bg); border-radius: 24px 24px 0 0;
  padding-top: 8px;
  padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  padding-left: max(22px, env(safe-area-inset-left, 0px));
  padding-right: max(22px, env(safe-area-inset-right, 0px));
  display: grid; gap: 18px;
  box-shadow: 0 -10px 30px -12px rgba(55, 40, 35, .3);
  animation: up .28s cubic-bezier(.2, .8, .2, 1);
}
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line); justify-self: center; }
.bottom-sheet h2 { margin: 0; font-family: var(--f-title); font-weight: 400; font-size: calc(var(--title-size) * .78); line-height: 1.1; color: var(--title-color); }
.sheet-form { display: grid; gap: 18px; }
.field { display: grid; gap: 8px; }
.field-label { font-size: 11.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.field input[type="text"], .field textarea {
  width: 100%; font-family: var(--f-body); font-size: max(17px, var(--body-size));
  padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--input-bg); color: var(--ink);
}
.field textarea { resize: none; line-height: 1.35; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--title-color); }

.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06); position: relative; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--sheet-bg), 0 0 0 5px var(--sw-deep); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--input-bg); font-size: 16px; line-height: 1.2; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--sheet-bg); }

.btn {
  min-height: 46px; padding: 10px 20px; border-radius: 999px; border: 0;
  background: var(--btn-bg); color: var(--btn-ink); font-family: var(--f-label); font-size: 16px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn svg { width: 18px; height: 18px; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: #A6463B; color: #FFFFFF; }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: 14.5px; font-weight: 500; }
.btn:disabled { opacity: .35; cursor: default; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.order { display: flex; gap: 10px; flex-wrap: wrap; }
.link-danger { justify-self: start; border: 0; background: transparent; padding: 8px 0; color: #A6463B; font-family: var(--f-label); font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }
.confirm { display: grid; gap: 10px; padding: 14px 16px; border-radius: 16px; background: var(--input-bg); box-shadow: inset 0 0 0 1.5px var(--line); }
.confirm p { margin: 0; font-size: 15.5px; line-height: 1.45; }

.backup-row { display: flex; gap: 10px; flex-wrap: wrap; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { margin: 0; font-size: 14.5px; line-height: 1.45; color: var(--muted); }
.hint.strong { color: var(--ink); font-weight: 600; }
.version { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- oznámení dole ---------- */
.toast {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 14px;
  padding: 10px 10px 10px 18px; border-radius: 999px;
  background: var(--ink); color: var(--sheet-bg);
  font-family: var(--f-label); font-size: 15px;
  box-shadow: 0 10px 24px -10px rgba(55, 40, 35, .5);
  animation: fade .2s ease;
}
.toast button { border: 0; border-radius: 999px; padding: 8px 14px; background: var(--sheet-bg); color: var(--ink); font-weight: 600; font-size: 14.5px; }

@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .backdrop, .bottom-sheet, .toast { animation: none; }
  .check .box, .check svg, .task .text, .app-head { transition: none; }
}
