/* UI refined with unslop by Damir Sokolovsky, CC BY 4.0.
   https://github.com/heydamir/unslop */
:root {
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans KR", "Segoe UI", sans-serif;
  color: #202326;
  background: #f8f9fa;
  font-size: 16px;
  font-weight: 400;
  --surface: #fff;
  --raised: #f3f4f5;
  --border: #dfe2e5;
  --text: #202326;
  --secondary: #535a61;
  --muted: #687078;
  --accent: #245c99;
  --positive: #19805a;
  --negative: #b83c44;
  --ease: cubic-bezier(.22, 1, .36, 1);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
[hidden] { display: none !important; }
header {
  min-height: 64px;
  padding: 12px max(24px, calc((100% - 832px) / 2));
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 16px; font-weight: 600; white-space: nowrap; }
.header-actions { margin-left: 0; display: flex; align-items: center; gap: 8px; }
main { max-width: 880px; margin: 40px auto; padding: 0 24px 32px; }
.card { padding: 32px; margin-bottom: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
h1, h2, p { margin: 0; }
h1 { font-size: 28px; font-weight: 500; line-height: 1.3; }
h2 { font-size: 16px; font-weight: 500; }
.muted, .last-updated { color: var(--muted); font-size: 13px; }
#email { margin-left: auto; min-width: 0; overflow-wrap: anywhere; text-align: right; }
button {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 160ms var(--ease), background-color 160ms var(--ease), border-color 160ms var(--ease);
  touch-action: manipulation;
}
button:hover:not(:disabled) { background: var(--raised); border-color: #b8bfc6; }
button:focus-visible, summary:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
button:disabled { color: #767d84; background: var(--raised); border-color: transparent; cursor: not-allowed; }
.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.primary:hover:not(:disabled) { color: #fff; background: #1d4c80; border-color: #1d4c80; }
.danger { color: var(--negative); }
.danger:hover:not(:disabled) { color: #9c2d35; background: #fcf3f3; border-color: #dfbfc2; }
.quiet, #logout, .icon-button { color: var(--secondary); border-color: transparent; background: transparent; }
.icon-button { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 12px; flex-shrink: 0; }
.icon-button svg { width: 18px; height: 18px; stroke-width: 1.5; }
.status-line { display: flex; align-items: center; gap: 12px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.running, .dot.starting { background: var(--positive); }
.dot.stopped, .dot.stopping { background: var(--negative); }
.dot.partial { background: #a16d1e; }
.dot.starting, .dot.stopping { animation: status-pulse 1.4s ease-in-out infinite; }
.last-updated { display: block; margin-top: 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.state-error { margin-top: 16px; color: var(--negative); font-size: 14px; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.actions .danger { margin-left: auto; }
.control-notice { margin-bottom: 16px; color: #8a601f; font-size: 13px; }
.resource-details { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.resource-indicator { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.resource-lamp { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.resource-phase { color: var(--muted); font-size: 12px; font-weight: 400; }
.is-on .resource-lamp { background: var(--positive); }
.is-on .resource-value { color: var(--positive); }
.is-off .resource-lamp { background: var(--negative); }
.is-off .resource-value { color: var(--negative); }
.is-unknown .resource-value { color: var(--muted); }
.is-transitioning .resource-lamp, .is-transitioning .resource-value { animation: status-pulse 1.4s ease-in-out infinite; }
.history { padding: 24px 32px; }
.history ol { list-style: none; padding: 0; margin: 16px 0 0; }
.history li { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; padding: 16px 0; border-top: 1px solid var(--border); font-size: 13px; }
.history li:last-child { padding-bottom: 0; }
.history li span { min-width: 0; overflow-wrap: anywhere; }
.history time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#message { color: var(--negative); text-align: center; white-space: pre-line; overflow-wrap: anywhere; font-size: 14px; }
#message:empty, #setup:empty, #users-message:empty, #group-message:empty, .note:empty { display: none; }
.login { max-width: 480px; margin: 80px auto 0; padding: 40px; }
.login h1 { font-size: 28px; }
.login > p { margin-top: 16px; color: var(--secondary); font-size: 14px; }
#google-button { display: flex; justify-content: flex-start; margin-top: 32px; min-height: 44px; }
dialog { max-width: calc(100% - 32px); max-height: calc(100dvh - 32px); margin: auto; padding: 24px; overflow: auto; overscroll-behavior: contain; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px #0000000f; }
body:has(dialog[open]) { overflow: hidden; }
dialog::backdrop { background: #20232666; }
#extension-dialog, #start-dialog { width: 520px; }
#settings-dialog { width: 720px; }
.modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.modal-heading h2 { font-size: 20px; }
.modal-heading .icon-button { margin-right: -8px; }
.users > .muted { color: var(--secondary); }
.user-form { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.user-form > div { flex: 1; min-width: 220px; }
.user-form label { display: block; margin-bottom: 8px; font-size: 13px; }
.user-form input { width: 100%; min-height: 44px; padding: 8px 12px; color: var(--text); background: var(--surface); border: 1px solid #b8bfc6; border-radius: 8px; font: inherit; font-size: 16px; }
.user-form input::placeholder { color: var(--muted); }
#users-list { list-style: none; margin: 24px 0 0; padding: 0; }
#users-list li { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; padding: 12px 0; border-top: 1px solid var(--border); font-size: 14px; }
#users-list span { min-width: 0; overflow-wrap: anywhere; }
#users-message { margin-top: 16px; color: var(--secondary); font-size: 14px; }
.admin-badge { flex-shrink: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
.duration-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0; margin: 24px 0 32px; border: 0; }
.duration-options label { position: relative; min-width: 0; cursor: pointer; }
.duration-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.duration-options span { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 12px 4px; color: var(--secondary); border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-variant-numeric: tabular-nums; transition: background-color 160ms var(--ease), border-color 160ms var(--ease); }
.duration-options label:hover span { background: var(--raised); }
.duration-options input:checked + span { color: var(--accent); background: #f0f5fa; border-color: var(--accent); font-weight: 500; }
.duration-options input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@keyframes status-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 600px) {
  header { padding: 12px 16px; gap: 8px; flex-wrap: wrap; }
  .header-actions { gap: 4px; margin-left: auto; }
  #logout { padding: 8px; }
  main { margin: 24px auto; padding: 0 16px 24px; }
  #email { order: 1; flex-basis: 100%; margin-left: 0; text-align: left; }
  .card { padding: 24px; border-radius: 12px; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; margin-top: 24px; }
  .actions .danger { grid-column: 1 / -1; margin-left: 0; }
  .actions button { padding: 12px 8px; min-height: 48px; }
  .history li { flex-direction: column; align-items: flex-start; gap: 8px; }
  .login { margin-top: 48px; padding: 32px 24px; }
  .login h1 { font-size: 24px; }
  dialog { padding: 20px; }
  .user-form > div { flex-basis: 100%; min-width: 0; }
  .user-form button { flex: 1; }
  .modal-actions button { flex: 1; min-height: 48px; }
  .duration-options { grid-template-columns: repeat(2, 1fr); }
  .schedule-row { flex-wrap: wrap; }
}
@media (max-width: 360px) {
  .brand { font-size: 14px; }
  .card { padding: 20px; }
  .actions { grid-template-columns: 1fr; }
  .actions .danger { grid-column: auto; }
}

.session-loading { padding: 48px 0; color: var(--muted); font-size: 14px; text-align: center; }
#session-retry { margin-top: 16px; }
.history-pagination { display: flex; justify-content: flex-end; align-items: center; gap: 16px; margin-top: 24px; }
#history-page { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.dashboard-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.dashboard-header .last-updated { margin: 0; }
.group-card .status-line h2 { font-size: 22px; line-height: 1.3; }
.group-status { margin-left: auto; color: var(--secondary); font-size: 14px; white-space: nowrap; }
.remaining { margin-top: 16px; font-size: 18px; font-variant-numeric: tabular-nums; }
.next-event { margin-top: 8px; }
.resource-details summary { color: var(--secondary); font-size: 13px; cursor: pointer; }
.members, .plain-list { list-style: none; margin: 0; padding: 0; }
.members { padding-top: 8px; }
.members li, .plain-list > li { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.members li:first-child { border-top: 0; }
.member-order { width: 24px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; flex-shrink: 0; }
.member-name { display: flex; flex-direction: column; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.member-name small { font-size: 12px; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--secondary); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
#group-editor h3 { margin: 24px 0 8px; font-size: 14px; font-weight: 500; }
#group-editor h3 .muted { display: block; font-size: 12px; font-weight: 400; }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
input:not([type="radio"]):not([type="checkbox"]), select { min-height: 44px; padding: 8px 12px; color: var(--text); background: var(--surface); border: 1px solid #b8bfc6; border-radius: 8px; font: inherit; font-size: 16px; }
.number-input { width: 72px; }
.count-label, .time-label { display: flex; align-items: center; gap: 8px; color: var(--secondary); font-size: 13px; white-space: nowrap; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.inline-form select { flex: 1; min-width: 0; }
.note { margin-top: 8px; }
.schedule-row { flex-wrap: wrap; }
.days { display: flex; gap: 4px; }
.day { display: flex; flex-direction: column; align-items: center; font-size: 12px; cursor: pointer; }
#group-message { margin: 16px 0; color: var(--negative); font-size: 14px; }
#group-editor .modal-actions { margin-top: 24px; }
#group-delete { margin-right: auto; }
