:root {
  --bg: #0b1220;
  --bg-2: #111a2d;
  --panel: #16233b;
  --panel-2: #1f3152;
  --text: #ebf2ff;
  --muted: #a7b8d8;
  --ok: #15b97a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --accent: #46a0ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 10% 10%, #1f3152, #0b1220 60%);
  color: var(--text);
  line-height: 1.35;
}

header {
  padding: 14px 20px;
  background: rgba(11, 18, 32, 0.8);
  border-bottom: 1px solid rgba(167, 184, 216, 0.2);
  position: sticky;
  top: 0;
  backdrop-filter: blur(8px);
  z-index: 2;
}

h1, h2, h3, h4 {
  margin: 0;
}

.container {
  width: min(1200px, 95%);
  margin: 20px auto 40px;
}

.card {
  background: linear-gradient(135deg, rgba(31, 49, 82, 0.9), rgba(22, 35, 59, 0.9));
  border: 1px solid rgba(167, 184, 216, 0.2);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 10px;
  min-height: 44px;
  padding: 10px 14px;
  color: white;
  background: var(--accent);
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
}

button.secondary {
  background: #334155;
}

button.warn {
  background: var(--warn);
  color: #1f2937;
}

button.danger {
  background: var(--danger);
}

button.ok {
  background: var(--ok);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input, select {
  border: 1px solid rgba(167, 184, 216, 0.3);
  background: rgba(11, 18, 32, 0.7);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 9px;
  min-height: 42px;
  font-size: 16px;
}

small, .muted {
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.timer {
  border: 1px solid rgba(167, 184, 216, 0.3);
  border-radius: 12px;
  padding: 12px;
  background: rgba(11, 18, 32, 0.5);
}

.timer h4 {
  margin-bottom: 8px;
}

.timer .clock {
  font-size: 1.6rem;
  font-family: "Menlo", "SF Mono", monospace;
  margin: 8px 0;
  letter-spacing: 0.03em;
}

#runnerGraceText {
  min-height: 1.35em;
  margin: 6px 0 10px;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.ready { background: #334155; }
.badge.running { background: var(--ok); }
.badge.grace { background: var(--warn); color: #1f2937; }
.badge.paused { background: #64748b; }
.badge.stopped { background: var(--danger); }

.hidden {
  display: none;
}

.qr {
  width: 160px;
  height: 160px;
  max-width: 100%;
  border-radius: 10px;
  background: white;
}

.overlay-root {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 300px;
  max-width: 480px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(8, 15, 30, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
}

.overlay-time {
  font-size: 2.2rem;
  font-family: "Menlo", "SF Mono", monospace;
  font-weight: 700;
}

.overlay-list {
  margin-top: 8px;
  font-size: 1rem;
}

.overlay-list div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

@media (max-width: 720px) {
  .container {
    width: 96%;
    margin-top: 12px;
  }

  header {
    padding: 12px 14px;
  }

  .top-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .control-row > * {
    width: 100%;
  }

  .control-row input,
  .control-row select,
  .control-row button,
  .control-row a {
    width: 100%;
  }

  .control-row a button {
    width: 100%;
  }

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

  .runner-header {
    position: static;
  }

  .runner-container {
    margin-top: 8px;
    margin-bottom: 24px;
  }

  .runner-card {
    padding: 12px;
  }

  .runner-timer .clock {
    font-size: 2.4rem;
    margin: 12px 0;
  }

  .runner-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .runner-controls button {
    width: 100%;
    min-height: 54px;
    font-size: 18px;
  }

  .overlay-root {
    right: 10px;
    bottom: 10px;
    min-width: 230px;
  }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 11;
  width: 90%;
  max-width: 400px;
}

.modal-content {
  background: linear-gradient(135deg, rgba(31, 49, 82, 0.95), rgba(22, 35, 59, 0.95));
  border: 1px solid rgba(167, 184, 216, 0.3);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 16px;
}

.modal-content input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(167, 184, 216, 0.3);
  background: rgba(11, 18, 32, 0.8);
  color: var(--text);
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
}

.modal-content input::placeholder {
  color: var(--muted);
}

.modal-content input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(11, 18, 32, 0.9);
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-buttons button {
  flex: 1;
  min-height: 40px;
  font-size: 14px;
}
