/* Shared UI rules for the remocon application. */
body.dark {
  --app-bg: #121916;
  --app-surface: #1b2420;
  --app-raised: #24302a;
  --app-border: #35433b;
  --app-text: #edf4ef;
  --app-muted: #abbcb0;
  --app-accent: #a0e3bc;
  --app-accent-ink: #123121;
  --app-error: #ffb5ab;
  background: var(--app-bg);
  color: var(--app-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Noto Sans KR', sans-serif;
  padding-top: 72px;
  padding-left: 112px;
}
* { box-sizing: border-box; }
.app-content { max-width: 1120px; margin: 0 auto; padding: 32px 28px 64px; min-width: 0; }
.app-content h1 { font-size: clamp(26px, 3vw, 34px); line-height: 1.25; margin: 0 0 10px; font-weight: 700; letter-spacing: -.03em; }
.app-content h2, .app-dialog h2 { font-size: 20px; line-height: 1.4; font-weight: 650; margin: 0; }
.app-content h3 { font-size: 18px; line-height: 1.4; font-weight: 650; margin: 0; }
.app-content p, .app-dialog p { margin: 8px 0; line-height: 1.65; }
.muted { color: var(--app-muted); }
.eyebrow { color: var(--app-accent); font-size: 11px; font-weight: 700; letter-spacing: .16em; margin: 0 0 8px !important; }
.page-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.section-heading { margin: 36px 0 18px; }
.compact-heading { margin-bottom: 18px; }
.app-topbar { position: fixed; inset: 0 0 auto; height: 72px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: var(--app-bg); border-bottom: 1px solid var(--app-border); z-index: 10; }
.app-brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-size: 22px; font-weight: 750; letter-spacing: -.04em; color: var(--app-text); }
.app-brand img { width: 32px; height: 32px; object-fit: contain; }
.brand-dot { color: var(--app-accent); }
.connection-button { margin-left: auto; padding: 0 6px; background: transparent; height: auto; border-radius: 12px; color: var(--app-text); }
.status-badge { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; width: fit-content; font-size: 12px; font-weight: 600; border-radius: 999px; background: var(--app-raised); color: var(--app-muted); padding: 6px 10px; line-height: 1.4; white-space: nowrap; }
.status-badge i { font-size: 16px; width: 16px; height: 16px; }
.status-badge.online { color: #b2ebc8; background: #243d2e; }
.status-badge.offline { color: #ffcabf; background: #402d28; }
.app-sidebar { position: fixed; top: 72px; bottom: 0; left: 0; width: 112px; display: flex; flex-direction: column; gap: 6px; padding: 20px 8px; border-right: 1px solid var(--app-border); background: var(--app-bg); z-index: 9; overflow-y: auto; }
.app-sidebar > a, .sidebar-bottom button { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; padding: 12px 4px; min-height: 72px; border-radius: 14px; color: var(--app-muted); font-size: 12px; text-decoration: none; width: 100%; height: auto; margin: 0; }
.app-sidebar a.current, .menu-links a.current { background: #243d2e; color: var(--app-accent); }
.app-sidebar a:hover, .menu-links a:hover { background: var(--app-raised); }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; padding-top: 20px; }
.user-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.menu-toggle { display: none; }
button, .button { font-family: inherit; }
.app-content button, .app-dialog button, .app-content .button, .app-dialog .button { min-height: 44px; font-size: 14px; border-radius: 12px; margin: 0; gap: 7px; }
button.button-primary, a.button-primary { background: var(--app-accent); color: var(--app-accent-ink); font-weight: 650; }
button.button-danger { background: #ffc0b6; color: #4e1e19; font-weight: 650; }
.danger-text { color: var(--app-error); }
.app-content button.border, .app-content .button.border, .app-dialog button.border { border: 1px solid var(--app-border); color: var(--app-text); background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
:is(a, button, input, textarea, summary):focus-visible { outline: 2px solid var(--app-accent); outline-offset: 4px; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 200; transform: translateY(-160%); padding: 12px 20px; background: var(--app-accent); color: var(--app-accent-ink); border-radius: 10px; }
.skip-link:focus { transform: none; }
.device-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; }
.device-filters button { color: var(--app-muted); border: 1px solid var(--app-border); background: transparent; padding: 0 16px; }
.device-filters button.active { color: var(--app-accent-ink); background: var(--app-accent); border-color: var(--app-accent); }
.count { display: inline-flex; justify-content: center; align-items: center; font-size: 12px; min-width: 22px; padding: 2px 6px; border-radius: 8px; background: #ffffff14; vertical-align: middle; }
.device-filters .active .count { background: #12312114; }
.device-grid, .management-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 16px; }
.management-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr)); }
article.device-card, article.management-card, article.switch-card { margin: 0; background: var(--app-surface); color: var(--app-text); border: 1px solid var(--app-border); box-shadow: none; padding: 22px; border-radius: 20px; min-width: 0; }
.device-card { display: flex; flex-direction: column; }
.device-card-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.device-title { flex: 1; min-width: 0; }
.device-title h3 { overflow-wrap: anywhere; }
.device-title p { margin: 3px 0 0; font-size: 12px; }
.device-icon { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border: 1px solid var(--app-border); border-radius: 14px; color: var(--app-accent); background: var(--app-raised); }
.device-controls { padding: 0; margin-top: 22px; }
.control-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.control-buttons button { min-width: 64px; max-width: 100%; height: auto; padding: 10px 15px; white-space: normal; overflow-wrap: anywhere; }
.device-value { display: flex; flex-direction: column; gap: 4px; margin: 18px 0 0 !important; font-size: 13px; }
.device-value strong { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.device-details { margin-top: auto; padding-top: 20px; font-size: 12px; color: var(--app-muted); }
.device-details summary, .profile-details summary { padding: 8px 0; min-height: 40px; }
.device-details dl, .management-help dl { margin: 10px 0; }
.device-details dt, .management-help dt { font-weight: 650; color: var(--app-text); }
.device-details dd, .management-help dd { margin: 4px 0 12px; overflow-wrap: anywhere; }
.device-thumbnail { width: 100%; margin-top: 16px; border-radius: 12px; aspect-ratio: 16/9; object-fit: cover; }
.media-info { margin-top: 14px; }
.media-info p { margin: 4px 0; font-size: 13px; }
.media-title { font-weight: 600; }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 48px 24px; gap: 12px; border: 1px dashed var(--app-border); border-radius: 20px; background: var(--app-surface); }
.empty-state > i { font-size: 36px; width: 36px; height: 36px; color: var(--app-accent); }
.empty-state p { max-width: 440px; margin: 0; font-size: 14px; }
.empty-state .status-badge { align-self: center; }
.empty-state .button, .empty-state button { margin-top: 8px; }
.switch-card-row { display: flex; align-items: center; gap: 16px; }
.switch-card-row > div { flex: 1; }
.switch-card-row p { font-size: 12px; margin: 4px 0 0; }
.switch-card .switch { display: flex; align-items: center; min-width: 56px; min-height: 44px; }
.notice { border-radius: 14px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.notice-error { background: #402d28; border: 1px solid #74473e; color: var(--app-error); }
.inline-error { color: var(--app-error); font-size: 13px; line-height: 1.5; }
.account-profile { display: flex; align-items: flex-start; gap: 16px; border-bottom: 1px solid var(--app-border); padding-bottom: 24px; }
.profile-info { flex: 1; min-width: 0; }
.profile-info p { overflow-wrap: anywhere; font-size: 13px; }
.profile-details { font-size: 12px; color: var(--app-muted); }
.name-edit { display: flex; align-items: flex-end; gap: 10px; margin: 16px 0 20px; }
.name-edit .app-field { flex: 1; margin: 0; }
.app-field { margin: 16px 0; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.app-field > label { font-size: 13px; font-weight: 600; color: var(--app-muted); }
.app-field input, .app-field textarea { width: 100%; min-width: 0; height: 44px; margin: 0; padding: 10px 12px; border: 1px solid var(--app-border); background: var(--app-bg); color: var(--app-text); border-radius: 10px; font: inherit; font-size: 14px; }
.app-field textarea { height: auto; min-height: 110px; resize: vertical; }
.app-field input[aria-invalid='true'] { border-color: var(--app-error); }
.app-field input:focus, .app-field textarea:focus { border-color: var(--app-accent); }
.credential-input { display: flex; align-items: center; border: 1px solid var(--app-border); border-radius: 10px; background: var(--app-bg); }
.credential-input input { border: 0; background: transparent; }
.credential-input button { flex-shrink: 0; }
.credential-info { display: flex; gap: 12px; font-size: 13px; }
.credential-info p { font-size: 12px; }
.management-help { margin-top: 24px; padding: 16px 20px; border: 1px solid var(--app-border); border-radius: 16px; font-size: 13px; color: var(--app-muted); }
.management-help pre { padding: 16px; background: var(--app-bg); overflow-x: auto; border-radius: 10px; }
.management-help code { color: var(--app-accent); }
.form-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.app-dialog fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.app-dialog .key-options { display: flex; flex-wrap: wrap; gap: 10px 20px; padding: 12px 0; }
.key-options legend { color: var(--app-muted); font-size: 13px; padding-bottom: 8px; }
.key-options label { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; }
.key-options input { appearance: auto; accent-color: var(--app-accent); width: 18px; height: 18px; position: static; opacity: 1; }
dialog.app-dialog { inset: 0; margin: auto; transform: none; min-width: 0; width: min(520px, calc(100% - 40px)); height: fit-content; max-height: calc(100dvh - 48px); background: var(--app-surface); color: var(--app-text); border: 1px solid var(--app-border); border-radius: 22px; padding: 24px; transition: none; box-shadow: 0 24px 100px #0006; }
dialog.app-dialog[open] { transform: none; }
dialog.app-dialog::backdrop { display: block; background: #08100cbf; backdrop-filter: blur(4px); }
.dialog-heading { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 12px; }
.dialog-heading h2 { flex: 1; }
.dialog-heading button { flex-shrink: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.dialog-actions button { min-width: 88px; }
.app-dialog.device-form-dialog { width: min(560px, calc(100% - 40px)); }
.app-dialog.app-menu { margin: 0; inset: 0 auto 0 0; width: min(340px, calc(100% - 48px)); height: 100dvh; max-height: 100dvh; border-radius: 0 22px 22px 0; }
.menu-links { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.menu-links a { display: flex; justify-content: flex-start; gap: 14px; align-items: center; padding: 14px; min-height: 48px; border-radius: 12px; text-decoration: none; color: var(--app-muted); }
.menu-account { margin-top: 24px; border-top: 1px solid var(--app-border); padding-top: 16px; }
.menu-account > a { display: inline-block; padding: 12px; font-size: 13px; }
.login-content { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 12px 0 20px; gap: 16px; }
.login-content > img { width: 64px; height: 64px; }
.app-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100vw - 32px); padding: 14px 20px; border-radius: 14px; color: var(--app-accent); background: #243d2e; border: 1px solid #578868; box-shadow: 0 8px 24px #0004; font-size: 14px; }
@media (max-width: 899px) {
  body.dark { padding-left: 0; padding-top: 64px; }
  .app-topbar { height: 64px; padding: 0 16px; gap: 10px; }
  .app-sidebar { display: none; }
  .menu-toggle { display: inline-flex; }
  .app-content { padding: 24px 20px 48px; }
  .app-brand { font-size: 20px; }
  .app-brand img { width: 28px; height: 28px; }
}
@media (max-width: 599px) {
  .app-content { padding: 24px 16px 40px; }
  .page-heading { align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
  .page-heading > div { flex: 1; min-width: 180px; }
  .page-heading > button, .page-heading > .button { padding: 0 12px; }
  .page-heading p.muted { font-size: 13px; }
  .section-heading { gap: 12px; align-items: flex-start; }
  .section-heading p.muted { font-size: 12px; }
  .device-grid, .management-grid { grid-template-columns: 1fr; }
  article.device-card, article.management-card, article.switch-card { padding: 20px; border-radius: 18px; }
  .account-profile { flex-wrap: wrap; }
  .account-profile > button { margin-left: 60px; }
  .form-columns { grid-template-columns: 1fr; gap: 0; }
  dialog.app-dialog:not(.app-menu) { width: 100%; max-height: calc(100dvh - 24px); border-radius: 22px 22px 0 0; margin: auto 0 0; padding: 24px 20px; }
  .dialog-actions { position: sticky; bottom: -24px; background: var(--app-surface); padding: 16px 0 4px; margin-top: 16px; }
  .dialog-actions button { flex: 1; }
  .notice { flex-wrap: wrap; }
  .connection-button { padding: 0; }
  .connection-button .status-badge { padding: 6px 8px; font-size: 11px; }
  .app-toast { bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
.virtual-bulb { display: grid; place-items: center; padding: 24px 0 12px; color: var(--app-muted); }
.virtual-bulb svg { fill: currentColor; width: 130px; height: 130px; }
.virtual-bulb.lit { color: var(--app-accent); }
.virtual-actions { margin-top: 16px; }
/* Explicit geometry avoids BeerCSS defaults for generic main/header/article tags. */
main.app-content { width: 100%; justify-self: center; }
.app-content header.page-heading { padding: 0; min-height: 0; height: auto; }
.device-grid > article.device-card, .management-grid > article.management-card, .grid > div > article.switch-card { margin: 0; }
.device-card-heading .device-title h3, .switch-card-row h3 { margin: 0; }
.device-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.device-grid > article.device-card, .management-grid > article.management-card, .grid > div > article.switch-card { margin-block-start: 0 !important; }
.app-content header.page-heading { background: transparent; }
@media (max-width: 599px) { .device-grid { grid-template-columns: 1fr; } }
