:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #232735;
  --border: #2e3242;
  --text: #e6e8ee;
  --muted: #8b90a0;
  --primary: #6366f1;
  --primary-hover: #545bd8;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1b1f2e, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 20px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.badge-off {
  background: #3a2030;
  color: #f2a1b6;
}
.badge-on {
  background: #123222;
  color: #7ee2a8;
}

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 16px;
}
.icon-btn:hover {
  background: var(--border);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

h1 {
  margin: 0 0 6px;
  font-size: 22px;
}
h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}
.center {
  text-align: center;
}

code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="url"],
input[type="password"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  width: 100%;
}
input:focus {
  outline: none;
  border-color: var(--primary);
}
input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 560px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-primary:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--text);
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-lg {
  padding: 16px 24px;
  font-size: 18px;
  min-width: 160px;
}

.select-wrap {
  position: relative;
}

.issue-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.issue-row .select-wrap {
  flex: 1;
  min-width: 0;
}
.refresh-btn {
  flex: 0 0 42px;
  width: 42px;
  height: auto;
  font-size: 18px;
  line-height: 1;
}
.refresh-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.refresh-btn.spinning {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: var(--shadow);
}
.dropdown li {
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
}
.dropdown li:hover,
.dropdown li.active {
  background: var(--primary);
  color: white;
}
.dropdown li .sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.dropdown li:hover .sub,
.dropdown li.active .sub {
  color: #dfe0ff;
}
.dropdown .empty {
  color: var(--muted);
  cursor: default;
}
.dropdown .empty:hover {
  background: transparent;
  color: var(--muted);
}

.pill {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
}
.pill .x {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}
.pill .x:hover {
  color: var(--danger);
}

.timer-card {
  text-align: center;
}
.timer {
  font-size: 64px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  margin: 4px 0 18px;
}
.timer.running {
  color: var(--success);
}
.note-label {
  text-align: left;
  margin-bottom: 16px;
}
.timer-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.status {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.status.ok {
  background: #123222;
  color: #7ee2a8;
}
.status.err {
  background: #3a2030;
  color: #f2a1b6;
}

.error {
  background: #3a2030;
  color: #f2a1b6;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.history .h-main {
  min-width: 0;
}
.history .h-issue {
  font-weight: 600;
}
.history .h-note {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
.history .h-dur {
  font-weight: 700;
  color: var(--success);
  white-space: nowrap;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal-box {
  max-width: 420px;
  width: 100%;
  margin: 0;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}

[hidden] {
  display: none !important;
}
