/* ============ tokeny ============ */
:root {
  --bg: #0b0d16;
  --bg-2: #11142195;
  --surface: #151a2c;
  --surface-2: #1c2238;
  --line: #2a3150;
  --line-soft: #232a44;
  --text: #e9ecf8;
  --muted: #949ec2;
  --faint: #6b7499;

  --accent: #7c5cff;
  --accent-2: #00e0b8;
  --hot: #ff3d81;
  --warn: #ffb020;
  --danger: #ff5c6c;
  --ok: #38d996;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --glow: 0 0 28px rgba(124, 92, 255, .45);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(124, 92, 255, .20), transparent 60%),
    radial-gradient(800px 460px at 92% 4%, rgba(0, 224, 184, .13), transparent 62%);
  background-attachment: fixed;
}

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.02em; }

button { font: inherit; color: inherit; }

::selection { background: rgba(124, 92, 255, .45); }

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ============ formularze ============ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.input, .select, .textarea, .search, input[type="text"], input[type="password"], input[type="number"], input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  background: #0e1220;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  transition: border-color .15s, box-shadow .15s;
}

.textarea { resize: vertical; min-height: 90px; font-family: inherit; }

.input:focus, .select:focus, .textarea:focus, .search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, .18);
  outline: none;
}

.select { appearance: none; cursor: pointer; padding-right: 32px; }

.check { display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--muted); font-size: .92rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

.hint { margin: 0; font-size: .82rem; color: var(--faint); }
.error { margin: 0; padding: 9px 12px; background: rgba(255, 92, 108, .12); border: 1px solid rgba(255, 92, 108, .35); border-radius: var(--radius-sm); color: #ffb3bb; font-size: .88rem; }

/* ============ przyciski ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 600; font-size: .92rem;
  cursor: pointer;
  transition: transform .12s, box-shadow .2s, background .2s, border-color .2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: linear-gradient(135deg, var(--accent), #5d7bff); color: #fff; box-shadow: 0 8px 22px rgba(124, 92, 255, .35); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 30px rgba(124, 92, 255, .5); }

.btn-ghost { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); }

.btn-danger { background: rgba(255, 92, 108, .14); border-color: rgba(255, 92, 108, .4); color: #ff9aa4; }
.btn-danger:hover:not(:disabled) { background: rgba(255, 92, 108, .24); }

.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; font-size: 1rem;
  transition: border-color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn::-webkit-details-marker { display: none; }

/* ============ ekran logowania ============ */
.gate { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.gate-card {
  width: min(400px, 100%);
  padding: 34px 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.gate-logo { font-size: 3rem; filter: drop-shadow(0 0 18px rgba(124, 92, 255, .6)); }
.gate-title { margin: 6px 0 4px; font-size: 1.9rem; }
.gate-sub { margin: 0 0 22px; color: var(--muted); font-size: .92rem; }
.oauth-list { display: flex; flex-direction: column; gap: 10px; }
.oauth-list .btn { text-decoration: none; }
.oauth-or { margin: 18px 0 14px; color: var(--faint); font-size: .8rem; }
#gate-error { margin-top: 14px; }
.form { display: flex; flex-direction: column; gap: 14px; text-align: left; }

/* ============ układ aplikacji ============ */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 12px clamp(14px, 3vw, 28px);
  background: rgba(11, 13, 22, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -.02em; }
.brand-icon { font-size: 1.3rem; filter: drop-shadow(0 0 10px rgba(124, 92, 255, .7)); }
.brand-name { font-size: 1.05rem; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 999px; }
.tab {
  padding: 7px 18px; border: none; border-radius: 999px; background: transparent;
  color: var(--muted); font-weight: 600; font-size: .9rem; cursor: pointer; transition: all .18s;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.tab-accent.is-active { background: linear-gradient(135deg, var(--accent), var(--hot)); color: #fff; box-shadow: var(--glow); }

.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.stat-pills { display: flex; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-soft);
  font-size: .78rem; font-weight: 600; color: var(--muted);
}
.pill b { color: var(--text); font-variant-numeric: tabular-nums; }
.pill-done b { color: var(--ok); }
.pill-doing b { color: var(--warn); }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 190px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); z-index: 40;
}
.menu-user { margin: 4px 8px 8px; font-size: .82rem; color: var(--faint); border-bottom: 1px solid var(--line-soft); padding-bottom: 8px; }
.menu-item {
  display: block; width: 100%; padding: 9px 10px; text-align: left;
  background: none; border: none; border-radius: 8px; cursor: pointer; font-size: .9rem;
}
.menu-item:hover { background: var(--surface-2); }

/* ============ widoki ============ */
.view { display: none; flex: 1; padding: clamp(16px, 3vw, 28px); }
.view.is-active { display: block; }
.arcade.is-active { display: flex; }

/* ---- lista ---- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  max-width: 1080px; margin: 0 auto 18px;
}
.search { flex: 1 1 220px; min-width: 180px; }
.filters { display: flex; gap: 5px; padding: 4px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 999px; }
.chip {
  padding: 6px 14px; border: none; border-radius: 999px; background: transparent;
  color: var(--muted); font-size: .84rem; font-weight: 600; cursor: pointer; transition: all .15s;
}
.chip:hover { color: var(--text); }
.chip.is-active { background: var(--accent); color: #fff; }
.select { flex: 0 0 auto; width: auto; min-width: 150px; }

.task-list { display: flex; flex-direction: column; gap: 10px; max-width: 1080px; margin: 0 auto; }

.task {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--prio-color, var(--line));
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color .18s, transform .12s, box-shadow .18s;
}
.task:hover { border-color: var(--line); box-shadow: 0 8px 26px rgba(0, 0, 0, .28); }
.task.is-done { opacity: .55; }
.task.is-done .task-title { text-decoration: line-through; }
.task.is-doing { background: linear-gradient(180deg, rgba(255, 176, 32, .07), transparent 60%), var(--surface); }
.task.just-won { animation: winner-pop .8s ease; border-color: var(--accent-2); }

@keyframes winner-pop {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 224, 184, .6); }
  40% { transform: scale(1.015); box-shadow: 0 0 0 10px rgba(0, 224, 184, 0); }
  100% { transform: scale(1); }
}

.task-head { display: flex; align-items: flex-start; gap: 12px; }
.task-check {
  flex: 0 0 auto; width: 22px; height: 22px; margin-top: 2px;
  border: 2px solid var(--line); border-radius: 7px; background: transparent;
  cursor: pointer; display: grid; place-items: center; font-size: .7rem; color: transparent;
  transition: all .15s;
}
.task-check:hover { border-color: var(--ok); }
.task.is-done .task-check { background: var(--ok); border-color: var(--ok); color: #06231a; }

.task-main { flex: 1; min-width: 0; }
.task-title { font-size: 1rem; font-weight: 650; word-break: break-word; }
.task-desc { margin: 6px 0 0; color: var(--muted); font-size: .89rem; white-space: pre-wrap; word-break: break-word; }
.task-desc.is-clamped { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.task-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  font-size: .75rem; color: var(--muted); font-weight: 600;
}
.badge-tag { color: var(--accent-2); border-color: rgba(0, 224, 184, .25); background: rgba(0, 224, 184, .08); }
.badge-due-soon { color: var(--warn); border-color: rgba(255, 176, 32, .3); background: rgba(255, 176, 32, .09); }
.badge-due-late { color: var(--danger); border-color: rgba(255, 92, 108, .35); background: rgba(255, 92, 108, .1); }
.badge-doing { color: var(--warn); border-color: rgba(255, 176, 32, .3); }
.badge-nodraw { color: var(--faint); }
.badge-prio { color: var(--prio-color, var(--muted)); border-color: currentColor; }

.task-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.mini-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--line-soft); border-radius: 9px;
  cursor: pointer; font-size: .85rem; color: var(--muted); transition: all .15s;
}
.mini-btn:hover { border-color: var(--accent); color: var(--text); }

.progress { margin-top: 10px; display: flex; align-items: center; gap: 9px; }
.progress-bar { flex: 1; height: 5px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; transition: width .3s; }
.progress-text { font-size: .74rem; color: var(--faint); font-variant-numeric: tabular-nums; }

.sub-inline { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.sub-inline li { display: flex; align-items: center; gap: 9px; font-size: .87rem; color: var(--muted); }
.sub-inline input { width: 16px; height: 16px; accent-color: var(--accent-2); cursor: pointer; flex: 0 0 auto; }
.sub-inline li.done span { text-decoration: line-through; opacity: .6; }

.empty { max-width: 1080px; margin: 40px auto; text-align: center; color: var(--faint); }

/* ============ automat ============ */
.arcade { position: relative; justify-content: center; align-items: flex-start; overflow: hidden; }
.arcade-bg {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(600px 300px at 50% 0%, rgba(255, 61, 129, .16), transparent 70%),
    repeating-linear-gradient(115deg, transparent 0 22px, rgba(124, 92, 255, .035) 22px 44px);
}

.machine { position: relative; z-index: 1; width: min(720px, 100%); text-align: center; }
.machine-title { font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -.03em; }
.machine-title::after { content: " 🎲"; }
.machine-sub { margin: 8px 0 22px; color: var(--muted); font-size: .95rem; }

.reel-frame {
  position: relative;
  padding: 10px;
  border-radius: 22px;
  background: linear-gradient(160deg, #2b2150, #141830 55%, #10162c);
  border: 1px solid #3a3268;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .04) inset, 0 26px 60px rgba(0, 0, 0, .55), 0 0 50px rgba(124, 92, 255, .22);
}
.reel-frame.is-spinning { animation: rumble .09s linear infinite; }
.reel-frame.is-landed { animation: slam .55s cubic-bezier(.22, 1.4, .36, 1); }

@keyframes rumble {
  0% { transform: translate(0, 0); }
  25% { transform: translate(.7px, -.6px); }
  50% { transform: translate(-.6px, .5px); }
  75% { transform: translate(.4px, .6px); }
  100% { transform: translate(0, 0); }
}
@keyframes slam {
  0% { transform: scale(1.035); }
  60% { transform: scale(.992); }
  100% { transform: scale(1); }
}

.reel-window {
  position: relative; height: 128px; overflow: hidden;
  border-radius: 14px;
  background: #080b16;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .9);
}
.reel-glass {
  position: absolute; inset: 10px; z-index: 3; pointer-events: none; border-radius: 14px;
  background: linear-gradient(180deg, rgba(8, 11, 22, .96) 0%, rgba(8, 11, 22, .25) 22%, transparent 45%,
              transparent 55%, rgba(8, 11, 22, .25) 78%, rgba(8, 11, 22, .96) 100%);
}
.reel { will-change: transform; }
.reel-item {
  height: 128px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; padding: 0 58px;
}
.reel-item .ri-title {
  font-size: clamp(1.05rem, 2.6vw, 1.5rem); font-weight: 750; letter-spacing: -.02em;
  /* max-width + anywhere: w kolumnie flex z align-items:center dlugi URL bez spacji
     rozpychal tytul poza okno bebna zamiast sie zawinac. */
  max-width: 100%; overflow-wrap: anywhere; text-align: center;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.reel-item .ri-meta { font-size: .76rem; color: var(--faint); font-family: var(--mono); }
.reel-item.is-winner .ri-title { color: var(--accent-2); text-shadow: 0 0 22px rgba(0, 224, 184, .55); }
.reel-item.idle .ri-title { color: var(--faint); font-weight: 600; }

.reel-marker {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 4;
  color: var(--hot); font-size: 1.15rem; text-shadow: 0 0 12px rgba(255, 61, 129, .8);
}
.reel-marker-l { left: 16px; }
.reel-marker-r { right: 16px; }

.machine-actions { margin: 24px 0 6px; }
.btn-lever {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 16px 52px;
  border: none; border-radius: 999px;
  background: linear-gradient(135deg, var(--hot), var(--accent) 60%, #4f7bff);
  color: #fff; cursor: pointer;
  box-shadow: 0 14px 40px rgba(255, 61, 129, .35), inset 0 1px 0 rgba(255, 255, 255, .3);
  transition: transform .12s, box-shadow .2s, filter .2s;
}
.btn-lever:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 20px 50px rgba(255, 61, 129, .5); }
.btn-lever:active:not(:disabled) { transform: translateY(2px) scale(.98); }
.btn-lever:disabled { filter: grayscale(.5) brightness(.8); cursor: wait; }
.lever-label { font-size: 1.25rem; font-weight: 850; letter-spacing: .12em; }
.lever-sub { font-size: .74rem; opacity: .85; letter-spacing: .04em; }

.draw-error { max-width: 460px; margin: 14px auto 0; }

.result {
  margin-top: 22px; padding: 22px;
  background: var(--surface); border: 1px solid rgba(0, 224, 184, .3);
  border-radius: 18px; box-shadow: 0 0 40px rgba(0, 224, 184, .12);
  animation: result-in .45s cubic-bezier(.2, .9, .3, 1.4);
}
@keyframes result-in {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.result-badge {
  display: inline-block; padding: 4px 14px; border-radius: 999px;
  background: rgba(0, 224, 184, .14); color: var(--accent-2);
  font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
}
.result-title { margin: 12px 0 0; font-size: 1.5rem; word-break: break-word; }
.result-desc { margin: 10px 0 0; color: var(--muted); font-size: .92rem; white-space: pre-wrap; text-align: left; }
.result-meta { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 14px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }

.options { margin-top: 26px; text-align: left; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.options summary { padding: 13px 16px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); list-style: none; }
.options summary::before { content: "⚙ "; }
.options[open] summary { border-bottom: 1px solid var(--line-soft); color: var(--text); }
.options-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; padding: 16px; }
.options-grid .select, .options-grid .input { width: 100%; }

.history { margin-top: 26px; text-align: left; }
.history-title { font-size: .82rem; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); margin-bottom: 10px; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.history-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 13px; background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 10px; font-size: .86rem;
}
.history-list .h-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-list .h-time { color: var(--faint); font-size: .76rem; font-variant-numeric: tabular-nums; }
.history-list .h-flag { font-size: .8rem; }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* ============ modale ============ */
.dialog {
  width: min(620px, calc(100vw - 28px));
  padding: 0; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.dialog-sm { width: min(430px, calc(100vw - 28px)); }
.dialog::backdrop { background: rgba(5, 7, 14, .72); backdrop-filter: blur(4px); }

.dialog-form { display: flex; flex-direction: column; max-height: min(86vh, 860px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.dialog-head h2 { font-size: 1.15rem; }
.dialog-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.dialog-foot { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line-soft); }
.spacer { flex: 1; }

.subtasks { border-top: 1px solid var(--line-soft); padding-top: 16px; }
.subtasks-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.subtask-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.subtask-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-2); border-radius: 9px; }
.subtask-list li span { flex: 1; font-size: .9rem; word-break: break-word; }
.subtask-list li.done span { text-decoration: line-through; color: var(--faint); }
.subtask-list input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent-2); cursor: pointer; }
.subtask-add { display: flex; gap: 8px; }

/* ============ toast ============ */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 90; padding: 11px 20px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: var(--shadow); font-size: .89rem;
  animation: toast-in .25s ease;
}
.toast.is-error { border-color: rgba(255, 92, 108, .5); color: #ffb3bb; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ responsywność ============ */
@media (max-width: 720px) {
  .stat-pills { display: none; }
  .brand-name { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .toolbar { gap: 8px; }
  .search { flex: 1 1 100%; }
  .select { flex: 1 1 auto; min-width: 0; }
  .task-head { flex-wrap: wrap; }
  .reel-window, .reel-item { height: 112px; }
  .reel-item { padding: 0 40px; }
  .btn-lever { padding: 14px 36px; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
