:root {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-soft: #111827;
  --card: #172033;
  --line: rgba(255,255,255,0.08);
  --text: #e5eefc;
  --muted: #98a5c2;
  --accent: #60a5fa;
  --accent-soft: rgba(96,165,250,0.14);
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --radius: 18px;
  --shadow: 0 12px 36px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #0b1220 0%, var(--bg) 100%);
  color: var(--text);
}
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.auth-card {
  width: min(460px, 100%);
  padding: 1.5rem;
}
.auth-copy {
  line-height: 1.6;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.25rem;
}
.auth-error {
  color: var(--red);
  margin-bottom: 0;
}
button, input, textarea, select {
  font: inherit;
}
button {
  border: 0;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
}
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
input, textarea, select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  padding: 0.85rem 0.95rem;
}
textarea { resize: vertical; min-height: 100px; }
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
  gap: 1.25rem;
  padding: 1.25rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.compact { padding: 1rem 1.2rem; }
.sidebar {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sidebar-header, .topbar, .detail-header, .section-head, .actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.actions-row.right {
  justify-content: flex-end;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: 0.76rem;
  margin: 0 0 0.2rem;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 1.5rem; margin-bottom: 0; }
.main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.badge, .status-pill, .mini-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
  border: 1px solid rgba(96,165,250,0.25);
}
.mini-pill {
  padding: 0.2rem 0.55rem;
  font-size: 0.74rem;
}
.idea-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: auto;
  padding-right: 0.2rem;
}
.idea-item {
  text-align: left;
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  padding: 1rem;
}
.idea-item.active {
  outline: 2px solid var(--accent);
  background: rgba(96,165,250,0.12);
}
.idea-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.idea-item-title { font-size: 1rem; }
.idea-item-niche, .muted { color: var(--muted); }
.idea-item-summary {
  color: #d7e2f6;
  margin-bottom: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.details {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.detail-header, .create-card, .compact-brief, .day-chat { padding: 1.2rem; }
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.grid > .card { padding: 1.1rem; }
.form-grid .full { grid-column: 1 / -1; }
.field {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.field span {
  color: var(--muted);
  font-size: 0.92rem;
}
.lead {
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 0;
}
.compact-brief {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.brief-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}
.brief-card, .day-summary, .add-entry-card {
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
}
.brief-card.full {
  grid-column: 1 / -1;
}
.brief-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.brief-card strong {
  font-size: 1rem;
}
.brief-card p {
  margin-bottom: 0;
  line-height: 1.55;
}
.day-chat {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.day-summary {
  font-size: 1.02rem;
  line-height: 1.6;
}
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.chat-entry {
  padding: 1rem 1.1rem;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(96,165,250,0.10) 0%, rgba(255,255,255,0.03) 100%);
  border: 1px solid rgba(96,165,250,0.18);
}
.chat-entry-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.65rem;
}
.chat-entry-time {
  color: var(--muted);
  font-size: 0.88rem;
}
.chat-entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.chat-entry-title {
  margin-bottom: 0.35rem;
  font-size: 1.02rem;
}
.chat-entry-text {
  margin-bottom: 0;
  line-height: 1.6;
  color: #dbe7fb;
}
.open-loops-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
}
.open-loop-item {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
}
.open-loop-item.done {
  opacity: 0.6;
}
.open-loop-checkbox {
  width: 18px;
  height: 18px;
  margin-top: 0.25rem;
}
.open-loop-content {
  flex: 1;
}
.open-loop-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}
.open-loop-title {
  line-height: 1.45;
}
.priority-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  border: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.priority-high {
  color: var(--red);
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.25);
}
.priority-medium {
  color: var(--yellow);
  background: rgba(251,191,36,0.12);
  border-color: rgba(251,191,36,0.25);
}
.priority-low {
  color: var(--green);
  background: rgba(52,211,153,0.12);
  border-color: rgba(52,211,153,0.25);
}
.open-loop-create {
  display: grid;
  grid-template-columns: 1fr 160px auto;
  gap: 0.75rem;
}
.empty {
  padding: 2rem;
  text-align: center;
}
.hidden { display: none !important; }
.create-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 0.75rem;
}
.status-nowy { color: var(--text); background: rgba(255,255,255,0.08); border-color: var(--line); }
.status-rozwijamy { color: var(--green); background: rgba(52,211,153,0.12); border-color: rgba(52,211,153,0.25); }
.status-do-przeanalizowania { color: #c084fc; background: rgba(192,132,252,0.12); border-color: rgba(192,132,252,0.25); }
.status-test, .status-do-sprawdzenia { color: var(--yellow); background: rgba(251,191,36,0.12); border-color: rgba(251,191,36,0.25); }
.status-odrzucony { color: var(--red); background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.25); }

@media (max-width: 1040px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .grid, .create-grid, .brief-grid {
    grid-template-columns: 1fr;
  }
  .detail-header, .sidebar-header, .topbar, .section-head, .chat-entry-meta {
    flex-direction: column;
    align-items: stretch;
  }
  .actions-row {
    width: 100%;
    flex-wrap: wrap;
  }
}
