:root {
  --bg: #eef2f7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: #ffffff;
  --text: #172033;
  --muted: #64748b;
  --border: rgba(148, 163, 184, 0.28);
  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --danger: #ef4444;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.10);
  --radius: 24px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: rgba(30, 41, 59, 0.82);
  --surface-strong: #1e293b;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.22);
  --primary: #818cf8;
  --primary-strong: #6366f1;
  --danger: #fb7185;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(79, 70, 229, 0.18), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.14), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 0.75rem 0.95rem;
  background: var(--primary);
  color: white;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, opacity 150ms ease;
}

button:hover {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger {
  background: transparent;
  color: var(--danger);
  padding: 0.25rem 0.4rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 0.8rem 0.9rem;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}

.app-shell {
  width: min(1440px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  margin-bottom: 1.6rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  letter-spacing: -0.06em;
}

h2 {
  margin: 0;
  font-size: 1.08rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  white-space: nowrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 1rem;
}

.card {
  min-height: 250px;
  padding: 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.wide-card {
  grid-column: span 2;
}

.clock-card,
.accent-card {
  background:
    linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(14, 165, 233, 0.10)),
    var(--surface);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-icon {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.clock-time {
  margin-top: 1.8rem;
  font-size: clamp(2.4rem, 6vw, 4.3rem);
  font-weight: 800;
  letter-spacing: -0.07em;
}

.clock-date {
  color: var(--muted);
  font-size: 1rem;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.stack-form {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.item-list {
  list-style: none;
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
}

.item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-strong);
}

.item.completed .item-text {
  text-decoration: line-through;
  color: var(--muted);
}

.item-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.item a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

.item a:hover {
  text-decoration: underline;
}

.check {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
}

.notes-area {
  min-height: 165px;
  resize: vertical;
  line-height: 1.5;
}

.hint {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.timer-display {
  margin: 1.4rem 0;
  text-align: center;
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: -0.07em;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1rem;
  color: var(--muted);
}

.setting-row input {
  max-width: 8rem;
}

.setting-row.column {
  align-items: stretch;
  flex-direction: column;
  gap: 0.45rem;
}

.setting-row.column input {
  max-width: none;
}

.countdown-result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  font-weight: 700;
  line-height: 1.4;
}

.calc-display {
  margin-bottom: 0.75rem;
  text-align: right;
  font-size: 1.45rem;
  font-weight: 700;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
}

.calc-grid button {
  min-height: 3rem;
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--border);
}

.calc-grid button:hover {
  background: var(--primary);
  color: white;
}

.calc-grid .equals {
  grid-row: span 2;
  background: var(--primary);
  color: white;
}

.calc-grid .span-two {
  grid-column: span 2;
}

.theme-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-top: 1.2rem;
}

.theme-preview span {
  min-height: 90px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.theme-preview span:nth-child(2) {
  background: linear-gradient(135deg, var(--primary), transparent);
}

.theme-preview span:nth-child(3) {
  background: var(--bg);
}

@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 1rem, 1440px);
    padding: 1rem 0;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .theme-toggle {
    justify-content: center;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .wide-card {
    grid-column: span 1;
  }

  .clock-time {
    margin-top: 1rem;
  }
}


.dashboard-tip {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.widget-card {
  position: relative;
  user-select: none;
}

.widget-card input,
.widget-card textarea,
.widget-card button,
.widget-card a {
  user-select: auto;
}

.widget-card.dragging {
  opacity: 0.48;
  transform: scale(0.985);
}

.widget-card.drag-over {
  outline: 3px dashed var(--primary);
  outline-offset: 5px;
}

.drag-handle {
  display: grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  margin-right: -0.15rem;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  cursor: grab;
  line-height: 1;
  font-weight: 800;
}

.drag-handle:active {
  cursor: grabbing;
}

.card-header h2 {
  margin-right: auto;
}

@media (hover: none) {
  .dashboard-tip {
    display: none;
  }
}
