:root {
  --bg: #0f172a;
  --card: #1e293b;
  --card-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --border: #334155;
  --high: #ef4444;
  --medium: #f59e0b;
  --low: #22c55e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1e293b 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.hero {
  text-align: center;
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: 2rem;
  margin: 0 0 0.5rem;
}

.hero p {
  color: var(--muted);
  margin: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

textarea {
  width: 100%;
  resize: vertical;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

textarea:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

button {
  background: var(--accent);
  color: #1f2937;
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover {
  background: var(--accent-2);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.ghost {
  background: transparent;
  color: var(--accent-2);
  border: 1px solid var(--border);
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
}

.status.error {
  color: var(--high);
}

.hidden {
  display: none;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: capitalize;
}

.badge.high {
  background: rgba(239, 68, 68, 0.15);
  color: var(--high);
}

.badge.medium {
  background: rgba(245, 158, 11, 0.15);
  color: var(--medium);
}

.badge.low {
  background: rgba(34, 197, 94, 0.15);
  color: var(--low);
}

.prio {
  font-weight: 800;
  width: 2rem;
  text-align: center;
  border-radius: 8px;
  padding: 0.15rem 0;
  display: inline-block;
}

.prio-1 { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.prio-2 { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.prio-3 { background: rgba(234, 179, 8, 0.15); color: #fde68a; }
.prio-4 { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.prio-5 { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }

/* Input group — textarea + toolbar */
.input-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-2);
  transition: border-color 0.15s;
}

.input-group:focus-within {
  border-color: var(--accent);
}

.input-group textarea {
  border: none;
  border-radius: 0;
  background: transparent;
  margin: 0;
}

.input-group textarea:focus {
  outline: none;
  border-color: transparent;
}

.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
  gap: 0.4rem;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.toolbar-btn:hover {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

.toolbar-btn.recording {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--high);
  color: #fca5a5;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
  animation: pulse-mic 1.5s ease-in-out infinite;
}

@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2); }
  50%      { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.08); }
}

.voice-status {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.voice-status.error {
  color: var(--high);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.history-empty {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  color: var(--muted);
  grid-column: 1 / -1;
}

/* Clickable run tiles */
.history-tile {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: var(--card-2);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.08s, box-shadow 0.15s;
  outline: none;
}

.history-tile:hover,
.history-tile:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.history-tile.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
}

.tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.tile-head-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tile-delete {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.1rem 0.25rem;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.history-tile:hover .tile-delete,
.history-tile:focus-within .tile-delete {
  opacity: 1;
}

.tile-delete:hover {
  color: var(--high);
  background: rgba(239, 68, 68, 0.12);
}

.history-tile.deleting {
  opacity: 0.4;
  pointer-events: none;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

button.ghost.danger {
  color: #fca5a5;
}

button.ghost.danger:hover {
  color: var(--high);
  border-color: var(--high);
  background: rgba(239, 68, 68, 0.08);
}

.tile-head .meta {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0;
}

.tile-view {
  color: var(--accent-2);
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.history-tile:hover .tile-view,
.history-tile:focus-visible .tile-view,
.history-tile.active .tile-view {
  opacity: 1;
}

.tile-preview {
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 0.55rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tile-chip {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.12);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  white-space: nowrap;
}

.tile-chip.accent { color: #38bdf8; background: rgba(56, 189, 248, 0.12); }
.tile-chip.high { color: var(--high); background: rgba(239, 68, 68, 0.12); }

/* Results header + viewing banner */
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.results-head h2 {
  margin: 0;
}

.viewing-banner {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 999px;
  padding: 0.3rem 0.4rem 0.3rem 0.85rem;
  font-size: 0.82rem;
  color: var(--accent-2);
  font-weight: 600;
}

button.ghost.small {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
}

/* Review step — confirm & edit voice tasks */
#reviewCard {
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.15), 0 10px 30px rgba(0, 0, 0, 0.25);
}

.review-head h2 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.review-sub {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.review-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.review-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.review-drag {
  color: var(--muted);
  font-size: 0.9rem;
  user-select: none;
  letter-spacing: -2px;
}

.review-input {
  flex: 1;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.92rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.review-input:focus {
  outline: none;
  border-color: var(--accent);
}

.review-input.unclear {
  border-color: var(--high);
  background: rgba(239, 68, 68, 0.08);
}

.review-remove {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.review-remove:hover {
  color: var(--high);
  border-color: var(--high);
  background: rgba(239, 68, 68, 0.1);
}

.add-task-btn {
  margin-bottom: 0.85rem;
  font-size: 0.85rem;
}

.review-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#confirmReviewBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Summary dashboard */
.summary-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.summary-stat {
  flex: 1 1 0;
  min-width: 100px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  text-align: center;
}
.summary-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
}
.summary-value.high { color: var(--high); }
.summary-value.accent { color: #38bdf8; }
.summary-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Quick wins callout */
.quick-wins {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.quick-wins h3 {
  margin: 0 0 0.4rem;
  font-size: 0.92rem;
  color: #38bdf8;
}
.quick-wins ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.quick-wins li {
  padding: 0.2rem 0;
  font-size: 0.88rem;
  color: var(--text);
}

/* Date cells */
.overdue { color: var(--high); font-weight: 700; }
.due-today { color: var(--high); font-weight: 600; }
.due-soon { color: var(--medium); font-weight: 600; }

/* Time cell */
.time-cell {
  font-weight: 600;
  white-space: nowrap;
  color: var(--accent);
}
.date-cell {
  white-space: nowrap;
}

/* Category badge */
.cat-badge {
  display: inline-block;
  font-size: 0.78rem;
  text-transform: capitalize;
  color: var(--muted);
  white-space: nowrap;
}

/* Quick-win inline badge */
.qw-badge {
  font-size: 0.7rem;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  margin-left: 0.3rem;
  font-weight: 700;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 1.5rem;
}
