:root {
  --bg: #f8f4ea;
  --ink: #1b1e27;
  --muted: #586070;
  --card: rgba(255, 251, 244, 0.88);
  --line: rgba(27, 30, 39, 0.08);
  --accent: #0ea5e9;
  --accent-strong: #0369a1;
  --warn: #f97316;
  --danger: #dc2626;
  --chip: rgba(14, 165, 233, 0.12);
  --shadow: 0 20px 40px rgba(12, 24, 40, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(14, 165, 233, 0.18), transparent 40%),
    radial-gradient(circle at 88% 20%, rgba(249, 115, 22, 0.18), transparent 35%),
    radial-gradient(circle at 62% 88%, rgba(14, 116, 144, 0.16), transparent 38%),
    var(--bg);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  line-height: 1.4;
  padding:
    calc(env(safe-area-inset-top, 0px) + 12px)
    14px
    calc(env(safe-area-inset-bottom, 0px) + 90px);
}

.ambient {
  position: fixed;
  inset: auto;
  border-radius: 999px;
  filter: blur(56px);
  pointer-events: none;
  z-index: -1;
}

.ambient-one {
  width: 260px;
  height: 260px;
  left: -80px;
  top: 10vh;
  background: rgba(14, 165, 233, 0.24);
}

.ambient-two {
  width: 300px;
  height: 300px;
  right: -120px;
  top: 55vh;
  background: rgba(249, 115, 22, 0.22);
}

.shell {
  width: min(860px, 100%);
  margin: 0 auto;
}

.hero {
  background: linear-gradient(140deg, rgba(11, 42, 68, 0.96), rgba(15, 118, 110, 0.9));
  color: #f8fafc;
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  right: -60px;
  top: -50px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
}

.hero-kicker {
  margin: 0;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  text-transform: uppercase;
  opacity: 0.86;
}

.hero h1 {
  margin: 6px 0 6px;
  font-family: "Sora", sans-serif;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.16;
}

.hero-sub {
  margin: 0;
  color: rgba(248, 250, 252, 0.88);
  font-size: 0.95rem;
}

.hero-clock {
  align-self: start;
  font-size: 1.15rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 14px;
  padding: 8px 12px;
  backdrop-filter: blur(7px);
}

.panel {
  margin-top: 16px;
}

.hidden {
  display: none !important;
}

.auth-card,
.alarm-board,
.modal-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 20px;
}

.auth-card h2 {
  margin: 0;
  font-family: "Sora", sans-serif;
}

.auth-sub {
  margin: 8px 0 18px;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.93rem;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
}

.row-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
}

.row-inline input[type="checkbox"] {
  width: auto;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.btn-secondary {
  background: rgba(14, 165, 233, 0.12);
  color: #0c4a6e;
}

.btn-danger {
  background: rgba(220, 38, 38, 0.14);
  color: #7f1d1d;
}

.auth-message {
  min-height: 1.2em;
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: #7f1d1d;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.welcome-row {
  margin-top: 14px;
}

.welcome-row h2 {
  margin: 0;
  font-family: "Sora", sans-serif;
  font-size: 1.4rem;
}

.welcome-row p {
  margin: 4px 0 0;
  color: var(--muted);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--chip);
  color: #0c4a6e;
  font-size: 0.84rem;
  font-weight: 600;
}

.chip-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.chip-off {
  opacity: 0.55;
}

.alarm-board {
  margin-top: 12px;
  padding: 16px;
}

.board-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.board-head h3 {
  margin: 0;
  font-family: "Sora", sans-serif;
}

.board-head p {
  margin: 0;
  color: var(--muted);
}

.alarm-list {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.empty-state {
  margin-top: 10px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 14px;
  color: var(--muted);
}

.empty-state p {
  margin: 0 0 8px;
}

.empty-state p:last-child {
  margin-bottom: 0;
}

.alarm-swipe {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
}

.alarm-actions {
  position: absolute;
  inset: 0 0 0 auto;
  width: 152px;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.alarm-actions button {
  border: 0;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.alarm-actions .action-edit {
  background: #0f766e;
}

.alarm-actions .action-delete {
  background: #b91c1c;
}

.alarm-card {
  position: relative;
  z-index: 1;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(12, 24, 40, 0.08);
  padding: 13px;
  touch-action: pan-y;
  transition: transform 0.2s ease;
}

.alarm-card.disabled {
  opacity: 0.5;
}

.alarm-main {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.alarm-main h4 {
  margin: 0;
  font-size: 1.02rem;
}

.alarm-meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.alarm-time {
  font-family: "Sora", sans-serif;
  font-size: 1.38rem;
  letter-spacing: 0.03em;
}

.alarm-bottom {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.alarm-eta {
  color: #0f172a;
  font-size: 0.86rem;
  font-weight: 600;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--muted);
}

.toggle input {
  width: auto;
}

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(145deg, #0ea5e9, #0369a1);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(14, 165, 233, 0.35);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(7, 14, 24, 0.5);
  backdrop-filter: blur(7px);
  padding:
    calc(env(safe-area-inset-top, 0px) + 14px)
    14px
    calc(env(safe-area-inset-bottom, 0px) + 14px);
  display: grid;
  align-items: center;
  justify-items: center;
}

.modal-card {
  width: min(560px, 100%);
  padding: 16px;
  max-height: min(86vh, 860px);
  overflow: auto;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-head h3 {
  margin: 0;
  font-family: "Sora", sans-serif;
}

.icon-btn {
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(14, 23, 38, 0.1);
  font-weight: 700;
  cursor: pointer;
}

.modal-form {
  display: grid;
  gap: 12px;
}

.wheel-wrap {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  background: rgba(11, 42, 68, 0.06);
  border-radius: 18px;
  padding: 10px;
}

.wheel-label {
  margin: 0 0 6px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.wheel {
  height: 220px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  border-radius: 14px;
  padding: 88px 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(245, 247, 250, 0.95));
  position: relative;
  mask-image: linear-gradient(to bottom, transparent 0, black 20%, black 80%, transparent 100%);
}

.wheel::before,
.wheel::after {
  content: "";
  position: sticky;
  left: 0;
  right: 0;
  height: 1px;
  border-top: 1px solid rgba(14, 165, 233, 0.35);
  border-bottom: 1px solid rgba(14, 165, 233, 0.35);
  pointer-events: none;
}

.wheel::before {
  top: 88px;
}

.wheel::after {
  top: 132px;
}

.wheel-item {
  height: 44px;
  display: grid;
  place-items: center;
  scroll-snap-align: center;
  font-size: 1.2rem;
  font-family: "Sora", sans-serif;
  color: #334155;
  transition: transform 0.18s ease, color 0.18s ease;
}

.wheel-item.active {
  color: #0369a1;
  transform: scale(1.04);
}

.wheel-divider {
  font-size: 2rem;
  color: #334155;
  margin-top: 22px;
}

.input-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.week-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.week-days button {
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.week-days button.active {
  border-color: #0284c7;
  background: rgba(14, 165, 233, 0.16);
  color: #0c4a6e;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.category-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.category-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.category-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.category-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.category-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.category-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.category-form {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.ring-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background:
    radial-gradient(circle at 50% 35%, rgba(14, 165, 233, 0.25), rgba(2, 6, 23, 0.78)),
    rgba(2, 6, 23, 0.82);
  display: grid;
  place-items: center;
  padding: 16px;
}

.ring-card {
  width: min(460px, 100%);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.8);
  padding: 22px;
  text-align: center;
  animation: ring-enter 260ms ease;
}

.ring-kicker {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #0c4a6e;
  font-size: 0.78rem;
  font-weight: 700;
}

.ring-card h3 {
  margin: 8px 0;
  font-family: "Sora", sans-serif;
  font-size: 1.7rem;
}

#ringTime {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: #334155;
}

.ring-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

@keyframes ring-enter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 720px) {
  body {
    padding-left: 20px;
    padding-right: 20px;
  }

  .toolbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .modal-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fab {
    right: max(20px, calc((100vw - 860px) / 2 + 20px));
  }
}
