.htd-quota {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem 1rem;
  margin: 0 0 1rem;
  padding: .65rem .85rem;
  border-radius: 12px;
  background: #eaf2ff;
  color: #183575;
  line-height: 1.45;
}
.htd-quota.exhausted { background: #fff1db; color: #743a09; }
.htd-quota > strong { display: flex; align-items: center; gap: .5rem; }
.htd-quota button, .htd-license-submit { background: #234dc3; border: 0; color: #fff; font-weight: 720; border-radius: 9px; cursor: pointer; }
.htd-quota button { padding: .55rem .85rem; }
.htd-quota button:hover, .htd-license-submit:hover { background: #173788; }
.htd-license-overlay { position: fixed; inset: 0; overflow: auto; display: flex; padding: clamp(.65rem, 3vw, 1.5rem); background: #10233a99; }
.htd-license-card { box-sizing: border-box; position: relative; width: min(100%, 32rem); margin: auto; padding: clamp(1rem, 4vw, 1.65rem); border-radius: 20px; background: #fff; color: #14254a; font: 1rem/1.5 system-ui, sans-serif; box-shadow: 0 16px 58px #07112666; }
.htd-license-card * { box-sizing: border-box; }
.htd-license-card button { font-family: inherit; min-height: 42px; }
.htd-license-card :focus-visible { outline: 3px solid #3c65ca; outline-offset: 3px; }
.htd-license-icon { display: block; border-radius: 14px; margin: 0 auto .65rem; }
.htd-license-close { position: absolute; top: .7rem; right: .7rem; width: 42px; border: 0; border-radius: 50%; background: #eef3fa; color: #28405d; font-size: 1.45rem; cursor: pointer; }
.htd-license-card h2 { text-align: center; font-size: clamp(1.35rem, 4vw, 1.65rem); line-height: 1.16; margin: .4rem 0 .7rem; }
.htd-license-card p { margin: .35rem 0; }
.htd-license-limit { text-align: center; color: #4a5d78; }
.htd-license-limit.exhausted { color: #813f0a; font-weight: 680; }
.htd-license-last { color: #21634d; text-align: center; font-size: .9rem; }
.htd-license-card form { display: grid; gap: .55rem; margin: 1rem 0; }
.htd-license-card label { font-weight: 720; }
.htd-license-card form input { width: 100%; min-height: 46px; border: 1px solid #aebfd8; border-radius: 9px; padding: .6rem .75rem; color: #14254a; background: #f7faff; }
.htd-license-card form input[aria-invalid=true] { border-color: #ba3442; }
.htd-license-error { color: #a22233; font-size: .9rem; }
.htd-license-submit { font-size: 1rem; padding: .55rem; }
.htd-device-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.htd-device-row input { flex: 1 1 13rem; min-width: 0; }
.htd-device-row button { padding: .4rem .55rem; border: 1px solid #aebfd8; border-radius: 8px; color: #183575; background: white; font-weight: 650; cursor: pointer; }
.htd-license-card button:disabled { opacity: .65; cursor: not-allowed; }

.htd-camera-options {
  display:grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap:8px;
  align-self:center;
  width:min(calc(100% - 24px),760px);
  margin:4px auto;
  font:500 13px/1.35 system-ui,sans-serif;
  color:#eaf1ff;
}
.htd-camera-option {
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
  min-height:46px;
  border-radius:13px;
  padding:6px 10px;
  border:1px solid #334869;
  background:#192841;
  box-sizing:border-box;
}
.htd-camera-option input { width:20px;height:20px;flex:none;accent-color:#6ee7b7; }
.htd-camera-option select {
  color:inherit;
  background:#192841;
  border:0;
  width:100%;
  min-width:0;
  font:inherit;
  font-size:16px;
  padding:4px 0;
}
.htd-camera-option:focus-within { outline:2px solid #6ee7b7;outline-offset:2px; }
@media(max-width:350px) { .htd-camera-options {grid-template-columns:1fr;} }

.htd-camera-screen,.htd-camera-permission {
  flex:1 1 0;
  min-width:0;
  min-height:0;
  overflow:auto;
  overscroll-behavior:contain;
}
.htd-camera-screen { display:flex;flex-direction:column;background:#0f172a; }
.htd-camera-workspace {
  flex:1 0 auto;
  display:flex;
  flex-direction:column;
  gap:8px;
  min-height:0;
  padding:8px 12px max(8px,env(safe-area-inset-bottom));
}
.htd-camera-controls {
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.htd-camera-controls .htd-camera-options,.htd-camera-permission .htd-camera-options {
  width:100%;
  margin:0;
}
.htd-camera-permission {
  display:grid;
  justify-items:center;
  align-items:safe center;
  background:#f5f7fb;
  padding:12px;
  box-sizing:border-box;
}
@media (min-width: 680px) and (orientation: landscape) {
  .htd-camera-workspace {flex-direction:row;}
  .htd-camera-controls {width:clamp(260px,31vw,380px);flex:none;}
  .htd-camera-controls .htd-camera-options {grid-template-columns:1fr;}
}

.htd-camera-notice {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  min-width:0;
  padding:10px 12px;
  background:#fbfcff;
  color:#172b49;
  border-left:4px solid #38a3a5;
  border-radius:10px;
  font:14px/1.4 system-ui,sans-serif;
}
.htd-camera-notice:has([role="alert"]) {border-left-color:#c58122;}
.htd-camera-notice > div {min-width:0;overflow-wrap:anywhere;}
.htd-camera-notice p {margin:3px 0 0;}
.htd-camera-notice button {
  flex:none;
  min-height:40px;
  padding:4px 10px;
  border:1px solid #bacbe2;
  border-radius:8px;
  background:#eaf1fb;
  color:#15385f;
  font:600 14px system-ui,sans-serif;
  cursor:pointer;
}

.htd-camera-permission {
  background:radial-gradient(ellipse at top,#dcf2ee,#f4f7fb 65%);
  padding:clamp(14px,4vw,38px);
  align-items:safe center;
}
.htd-camera-setup {
  box-sizing:border-box;
  width:min(100%,490px);
  padding:clamp(17px,5vw,32px);
  border:1px solid #d8e7e6;
  border-radius:22px;
  background:white;
  box-shadow:0 14px 45px #22404d16;
  color:#152d40;
  font:15px/1.45 system-ui,sans-serif;
}
.htd-camera-setup h1 {font-size:clamp(21px,6vw,29px);line-height:1.2;margin:14px 0 6px;}
.htd-camera-setup p {margin:0 0 18px;color:#506578;}
.htd-camera-mark {display:grid;place-items:center;width:52px;height:52px;border-radius:14px;background:#dff3ed;margin-top:14px;}
.htd-camera-back,.htd-camera-primary {min-height:44px;font:700 15px system-ui,sans-serif;cursor:pointer;border-radius:10px;}
.htd-camera-back {background:#eef4f4;color:#315765;border:0;padding:0 10px;}
.htd-camera-primary {background:#13736b;color:white;border:1px solid #13736b;padding:8px 12px;}
.htd-camera-setup-actions {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-bottom:16px;}
.htd-camera-setup .htd-camera-options {gap:8px;grid-template-columns:1fr;}
.htd-camera-setup .htd-camera-option,.htd-camera-setup select {background:#f3f8f8;color:#233d50;border-color:#d4e3e5;}
.htd-camera-setup .htd-camera-option input {accent-color:#13736b;}
@media(max-width:410px){.htd-camera-setup-actions {grid-template-columns:1fr;}}

.htd-camera-options {
  grid-template-columns:minmax(0,1fr);
  gap:6px;
}
.htd-camera-option {min-height:44px;}
.htd-camera-option > span {min-width:0;overflow-wrap:anywhere;}
.htd-camera-template {
  display:grid;
  grid-template-columns:minmax(0,auto) minmax(0,1fr);
  gap:8px;
}
.htd-camera-template > span {font-weight:650;}
.htd-camera-option select {text-overflow:ellipsis;}
.htd-camera-setup {
  display:grid;
  min-width:0;
  gap:16px;
  width:min(100%,450px);
  padding:clamp(15px,4vw,26px);
}
.htd-camera-setup-heading {
  display:grid;
  grid-template-columns:46px minmax(0,1fr);
  align-items:center;
  gap:12px;
}
.htd-camera-setup h1 {margin:0 0 4px;overflow-wrap:anywhere;}
.htd-camera-setup p {margin:0;}
.htd-camera-setup .htd-camera-mark {width:46px;height:46px;margin:0;}
.htd-camera-back {justify-self:start;}
.htd-camera-setup-actions {margin:0;}
.htd-camera-primary,.htd-camera-secondary {
  width:100%;
  box-sizing:border-box;
  min-height:46px;
  line-height:1.35;
  overflow-wrap:anywhere;
}
.htd-camera-secondary {
  color:#174b48;
  background:#f2f8f7;
  border:1px solid #c1d5d3;
  border-radius:10px;
  padding:8px 12px;
  font:700 15px/1.35 system-ui,sans-serif;
  cursor:pointer;
}
.htd-camera-setup button:focus-visible {outline:2px solid #13736b;outline-offset:3px;}
@media (max-width:340px) {
  .htd-camera-template {grid-template-columns:minmax(0,1fr);gap:2px;}
}

.htd-camera-workspace {
  flex-direction:column;
  gap:4px;
  padding:4px 5px max(4px,env(safe-area-inset-bottom));
}
.htd-camera-stage {
  position:relative;
  display:flex;
  min-width:0;
  min-height:200px;
  flex:1 1 0;
}
.htd-camera-controls {
  flex:0 0 auto;
  width:auto;
  display:flex;
  flex-direction:row;
  align-items:center;
  gap:4px;
  padding-inline:6px;
}
.htd-camera-popup {
  position:absolute;
  z-index:4;
  inset:auto 10px 10px;
  width:auto;
  max-width:460px;
  max-height:65%;
  margin-inline:auto;
  overflow:auto;
  box-shadow:0 8px 24px #0007;
}
.htd-camera-setup > .htd-camera-popup {position:static;max-height:none;box-shadow:none;margin:0;}
.htd-camera-popup > div > button {margin-top:6px;}
.htd-camera-options-menu {position:relative;flex:none;color:#eaf1ff;font:14px/1.4 system-ui,sans-serif;}
.htd-camera-options-menu > summary {
  display:grid;
  place-items:center;
  list-style:none;
  width:44px;
  min-height:44px;
  border-radius:11px;
  background:#192841;
  cursor:pointer;
}
.htd-camera-options-menu > summary::-webkit-details-marker {display:none;}
.htd-camera-options-panel {
  position:absolute;
  z-index:6;
  right:0;
  bottom:calc(100% + 8px);
  width:min(300px,calc(100vw - 24px));
  max-height:calc(100vh - 82px);
  max-height:calc(100dvh - 82px);
  overflow:auto;
  overscroll-behavior:contain;
  box-sizing:border-box;
  border:1px solid #334869;
  border-radius:12px;
  padding:8px;
  background:#121e32;
  box-shadow:0 8px 24px #0008;
}
.htd-camera-options-panel > button {margin-top:8px;min-height:38px;border-radius:8px;border:1px solid #527096;color:#eaf1ff;background:#203653;cursor:pointer;}
.htd-camera-workspace:has(.htd-camera-options-menu[open]) .htd-camera-popup {visibility:hidden;}

.htd-camera-notice[data-tone] {border-left-color:var(--notice-edge);background:var(--notice-surface);}
.htd-camera-notice-icon {
  width:36px;height:36px;flex:none;display:grid;place-items:center;border-radius:10px;
  color:var(--notice-ink);background:var(--notice-chip);
}
.htd-camera-notice[data-tone="blue"] {--notice-edge:#2d6bc3;--notice-ink:#2459a5;--notice-chip:#dbeaff;--notice-surface:#f4f8ff;}
.htd-camera-notice[data-tone="green"] {--notice-edge:#188359;--notice-ink:#126445;--notice-chip:#d4f3e5;--notice-surface:#f0fcf6;}
.htd-camera-notice[data-tone="amber"] {--notice-edge:#a76808;--notice-ink:#845100;--notice-chip:#ffedb6;--notice-surface:#fffbef;}
.htd-camera-notice[data-tone="orange"] {--notice-edge:#c25717;--notice-ink:#93400e;--notice-chip:#ffe3ca;--notice-surface:#fff7ed;}
.htd-camera-notice[data-tone="violet"] {--notice-edge:#7850b8;--notice-ink:#60389a;--notice-chip:#efddff;--notice-surface:#faf5ff;}
.htd-camera-notice[data-tone="red"] {--notice-edge:#c2434d;--notice-ink:#9a2a35;--notice-chip:#ffe0e3;--notice-surface:#fff5f6;}
.htd-camera-notice[data-tone] strong {color:var(--notice-ink);}
.htd-camera-notice[data-tone] > div {flex:1;}
@media(max-width:350px){
  .htd-camera-notice[data-tone] {gap:6px;padding:9px;}
  .htd-camera-notice-icon {width:28px;height:28px;}
}
