:root {
  color-scheme: dark;
  --bg: #101010;
  --panel: #1f1f1f;
  --panel-2: #2b2b2b;
  --text: #ffffff;
  --muted: #999999;
  --line: rgba(255, 255, 255, 0.16);
  --danger: #d60000;
  --focus: #58c7ff;
  --row-h: 74px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 3px);
  background: var(--bg);
}

.timeline {
  flex: 1;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  overflow: hidden;
}

.timeline:empty {
  display: grid;
  place-items: center;
}

.event {
  min-height: var(--row-h);
  height: auto;
  background: var(--panel);
  border-bottom: 1px solid rgba(0, 0, 0, 0.28);
  overflow: hidden;
  transform: translateY(0);
  transition: height 820ms cubic-bezier(0.22, 1, 0.36, 1), opacity 540ms ease, background-color 260ms ease;
}

.event-inner {
  min-height: var(--row-h);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  grid-template-rows: auto 1fr;
  gap: 6px 8px;
  align-items: start;
  padding: 10px 10px 12px;
  transition: transform 820ms cubic-bezier(0.22, 1, 0.36, 1), opacity 540ms ease;
}

.event:nth-child(odd) {
  background: var(--panel-2);
}

.event.is-terminal {
  background: var(--danger);
  animation: terminal-pulse 3s ease-in-out infinite;
}

.event.is-expired {
  color: #d8d8d8;
  background: #5f5f5f;
  animation: none;
}

.event.is-leaving {
  min-height: 0;
  border-bottom-color: transparent;
  opacity: 0;
  pointer-events: none;
}

.event.is-leaving .event-inner {
  transform: translateY(-24px);
  opacity: 0;
}

.event-title {
  min-width: 0;
  margin: 0;
  font-size: clamp(0.9rem, 4vw, 1rem);
  font-weight: 760;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.event-clock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
  font-weight: 730;
  white-space: nowrap;
}

.event-clock svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.row-action {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  margin-top: -7px;
  margin-right: -6px;
  border: 0;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.8);
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.row-action svg {
  width: 19px;
  height: 19px;
}

.row-action:active {
  background: rgba(255, 255, 255, 0.16);
}

.event-countdown {
  grid-column: 1 / -1;
  justify-self: end;
  margin: 0;
  font-size: clamp(1.18rem, 7vw, 1.9rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.create-button {
  width: calc(100% - 24px);
  max-width: 516px;
  min-height: 52px;
  margin: 12px auto 0;
  border: 0;
  border-radius: 8px;
  color: #111111;
  background: #ffffff;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.create-button span {
  display: inline-block;
  margin-right: 8px;
  font-size: 1.2em;
  line-height: 0;
}

.notification-button {
  width: calc(100% - 24px);
  max-width: 516px;
  min-height: 44px;
  margin: 8px auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  font-weight: 750;
  cursor: pointer;
  touch-action: manipulation;
}

.notification-button:disabled {
  color: var(--muted);
  cursor: default;
}

.site-footer {
  min-height: 13px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
  line-height: 11px;
  text-align: center;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer a:focus-visible {
  outline: 1px solid var(--focus);
  outline-offset: 1px;
}

.create-button:focus-visible,
.notification-button:focus-visible,
.icon-button:focus-visible,
.edit-button:focus-visible,
.delete-button:focus-visible,
.submit-button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.event-dialog {
  width: min(calc(100% - 24px), 480px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #191919;
}

.event-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.event-form {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-header h1 {
  margin: 0;
  font-size: 1.12rem;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.field {
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 750;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #0d0d0d;
}

.input-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d0d0d;
}

.input-unit input {
  border: 0;
  border-radius: 0;
}

.input-unit span {
  padding: 0 12px;
  color: var(--muted);
  font-weight: 700;
}

.submit-button {
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: #0072ce;
  font-weight: 850;
  cursor: pointer;
}

@keyframes terminal-pulse {
  0%,
  100% {
    background-color: #d60000;
    box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0);
  }

  50% {
    background-color: #780000;
    box-shadow: inset 0 0 0 999px rgba(0, 0, 0, 0.22);
  }
}

@media (min-width: 680px) {
  body {
    background: #050505;
  }

  .app {
    max-width: 540px;
    margin: 0 auto;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
