:root {
  color-scheme: dark;
  --bg: #050907;
  --panel: rgba(13, 21, 17, 0.72);
  --panel-strong: rgba(10, 16, 13, 0.95);
  --line: #173425;
  --line-bright: #2bff9a;
  --text: #e5ffe8;
  --text-dim: #789382;
  --green: #2bff9a;
  --green-soft: #7cffb7;
  --orange: #ffb84d;
  --red: #ff8a78;
  --blue: #91d6ff;
  --disabled: #315044;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

button,
input {
  font: inherit;
}

body {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(43, 255, 154, 0.07) 0,
      rgba(43, 255, 154, 0.07) 1px,
      transparent 2px,
      transparent 9px
    ),
    linear-gradient(180deg, rgba(43, 255, 154, 0.06), transparent 34%);
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 3px,
      rgba(0, 0, 0, 0.26) 4px
    ),
    radial-gradient(circle at 50% 12%, rgba(43, 255, 154, 0.08), transparent 42%);
  mix-blend-mode: screen;
}

.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: min(100%, 620px);
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  gap: 8px;
}

.topbar {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 0 3px;
  border-top: 1px solid rgba(43, 255, 154, 0.09);
  border-bottom: 1px solid rgba(43, 255, 154, 0.12);
}

.face {
  position: relative;
  width: 68px;
  height: 48px;
  overflow: hidden;
  color: #53615a;
  background:
    radial-gradient(circle, currentColor 0 1px, transparent 1.4px) 0 0 / 6.8px 6.8px,
    rgba(7, 15, 11, 0.4);
  opacity: 0.9;
}

.face.connected {
  color: var(--green);
}

.face::before,
.face::after,
.mouth {
  position: absolute;
  content: "";
  display: block;
  background: currentColor;
  box-shadow: 0 0 8px color-mix(in srgb, currentColor 48%, transparent);
}

.face::before,
.face::after {
  top: 14px;
  width: 14px;
  height: 4px;
  border-radius: 2px;
}

.face::before {
  left: 10px;
  box-shadow:
    0 0 8px color-mix(in srgb, currentColor 48%, transparent),
    -1px 5px 0 -1px currentColor;
}

.face::after {
  right: 10px;
  box-shadow:
    0 0 8px color-mix(in srgb, currentColor 48%, transparent),
    12px 5px 0 -1px currentColor;
}

.eye {
  display: none;
}

.mouth {
  left: 24px;
  bottom: 10px;
  width: 20px;
  height: 4px;
  border-radius: 3px;
}

.face.listening .mouth {
  left: 21px;
  width: 26px;
  height: 4px;
  bottom: 12px;
  box-shadow:
    0 6px 0 currentColor,
    -3px 3px 0 -1px currentColor,
    23px 3px 0 -1px currentColor;
}

.face.thinking::before,
.face.thinking::after,
.face.thinking .mouth {
  animation: blink 0.5s steps(2) infinite;
}

.face.error::before,
.face.error::after,
.face.error .mouth {
  color: var(--red);
  background: var(--red);
  box-shadow: 0 0 8px rgba(255, 138, 120, 0.45);
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

.status-block {
  min-width: 0;
}

.title-row,
.status-line {
  display: flex;
  align-items: center;
  min-width: 0;
}

.title-row {
  gap: 8px;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.battery {
  min-width: 58px;
  max-width: 128px;
  padding: 3px 7px;
  border: 1px solid rgba(43, 255, 154, 0.75);
  border-radius: 5px;
  background: rgba(11, 18, 14, 0.67);
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-line {
  gap: 8px;
  margin-top: 6px;
  color: var(--green-soft);
  font-size: 12px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: visible;
}

.status-line span {
  flex: 0 0 auto;
  overflow: visible;
}

.sync-line {
  flex: 0 0 auto;
  color: var(--orange);
  font-size: 10px;
  font-weight: 800;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-button,
.primary,
.add-scheduled,
.install-banner button {
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--green);
  cursor: pointer;
}

.icon-button {
  width: 36px;
  height: 34px;
  padding: 0;
}

.icon-button.amber {
  color: var(--orange);
}

.icon-button.danger {
  color: var(--red);
}

.icon-button.blue {
  color: var(--blue);
}

button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  color: var(--disabled);
  opacity: 1;
}

.svg-icon {
  display: block;
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.icon-button .svg-icon {
  width: 25px;
  height: 25px;
}

.glyph {
  position: relative;
  display: inline-block;
  width: 24px;
  height: 24px;
  color: currentColor;
}

.glyph-calendar {
  border: 3px solid currentColor;
  border-radius: 2px;
}

.glyph-calendar::before,
.glyph-calendar::after {
  content: "";
  position: absolute;
  background: currentColor;
}

.glyph-calendar::before {
  left: 3px;
  right: 3px;
  top: 6px;
  height: 3px;
  box-shadow: 0 6px currentColor, 0 12px currentColor;
}

.glyph-calendar::after {
  left: 3px;
  top: -6px;
  width: 3px;
  height: 8px;
  box-shadow: 12px 0 currentColor;
}

.glyph-reset {
  border: 3px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
}

.glyph-reset::after {
  content: "";
  position: absolute;
  top: -4px;
  left: 2px;
  border-style: solid;
  border-width: 5px 7px 5px 0;
  border-color: transparent currentColor transparent transparent;
  transform: rotate(-22deg);
}

.glyph-qr::before,
.glyph-qr::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border: 3px solid currentColor;
}

.glyph-qr::before {
  left: 0;
  top: 0;
  box-shadow: 14px 0 0 -3px currentColor, 0 14px 0 -3px currentColor;
}

.glyph-qr::after {
  right: 0;
  bottom: 0;
  box-shadow: -9px -9px 0 -3px currentColor, -15px 0 0 -4px currentColor, 0 -15px 0 -4px currentColor;
}

.glyph-ble {
  display: grid;
  place-items: center;
  color: currentColor;
  font-size: 12px;
  font-weight: 900;
  transform: skewX(-8deg);
}

.install-banner,
.confirm-panel,
.console,
.composer,
.main-panel,
.calendar-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 21, 17, 0.88);
}

.install-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--text-dim);
  font-size: 12px;
}

.install-banner span {
  flex: 1;
}

.install-banner button {
  padding: 6px 10px;
  border: 1px solid var(--green);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
}

.confirm-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-color: var(--orange);
  background: #171507;
}

.confirm-count {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 3px solid var(--orange);
  border-radius: 50%;
  color: #ffe1a3;
  font-weight: 800;
}

.confirm-panel p {
  flex: 1;
  margin: 0;
  color: #ffe1a3;
  font-size: 13px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.main-panel,
.calendar-panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px;
}

.main-panel {
  background: transparent;
  border-color: transparent;
  padding-top: 2px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 100%;
  color: #476355;
  font-size: 13px;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-item {
  display: grid;
  grid-template-columns: 3px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  min-height: 35px;
  padding: 4px 1px 4px 8px;
  border: 1px solid rgba(43, 255, 154, 0.55);
  border-radius: 5px;
  background: rgba(13, 21, 17, 0.63);
}

.task-item.high {
  border-color: rgba(255, 209, 102, 0.65);
}

.task-item.low {
  border-color: rgba(145, 214, 255, 0.65);
}

.priority-bar {
  width: 3px;
  height: 18px;
  border-radius: 2px;
  background: var(--green);
}

.task-item.high .priority-bar {
  background: #ffd166;
}

.task-item.low .priority-bar {
  background: var(--blue);
}

.task-text {
  min-width: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
  font-size: 13px;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.task-date {
  max-width: 82px;
  overflow: hidden;
  color: #ffc45a;
  font-size: 10px;
  font-weight: 800;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-delete {
  width: 28px;
  height: 28px;
  color: var(--red);
}

.task-delete .svg-icon {
  width: 20px;
  height: 20px;
}

.trash-glyph {
  position: relative;
  width: 13px;
  height: 16px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 2px 2px;
}

.trash-glyph::before {
  content: "";
  position: absolute;
  left: -3px;
  right: -3px;
  top: -5px;
  height: 2px;
  background: currentColor;
  box-shadow: 5px -3px 0 -1px currentColor;
}

.calendar-panel {
  padding: 8px;
}

.calendar-head {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  margin-bottom: 8px;
}

.calendar-head strong {
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day {
  min-height: 48px;
  padding: 4px;
  border: 1px solid #1a3f2b;
  border-radius: 4px;
  background: rgba(11, 18, 14, 0.7);
  color: #83a48e;
  font-size: 10px;
}

.day.today {
  border-color: rgba(255, 184, 77, 0.75);
}

.day.selected {
  border-color: var(--green);
  background: #173523;
  color: var(--text);
}

.day .dots {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 14px;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
}

.add-scheduled {
  width: 100%;
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid var(--orange);
  border-radius: 6px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 800;
}

.console {
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.composer {
  display: block;
  padding: 7px;
  background: rgba(10, 16, 13, 0.95);
}

.composer-frame {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  align-items: end;
  gap: 8px;
}

.composer input {
  min-width: 0;
  width: 100%;
  min-height: 46px;
  border: 1px solid #eff5f0;
  border-radius: 23px;
  background: #eff5f0;
  color: #101611;
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1.25;
  outline: none;
}

.composer input::placeholder {
  color: #5d7468;
  opacity: 1;
}

.composer input:focus {
  border-color: #9af7ba;
}

.composer-action-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1.5px solid var(--green);
  border-radius: 50%;
  background: #111a14;
  color: var(--green);
  cursor: pointer;
  outline: none;
}

.composer-action-button:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 2px;
}

.composer-action-button.send {
  border-color: #4f72ff;
  color: #4f72ff;
}

.composer-action-button.stop {
  border-color: #ff7a45;
  color: #ff7a45;
}

.composer-action-button .svg-icon {
  width: 29px;
  height: 29px;
}

.send-glyph {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 17px solid currentColor;
}

.mic-glyph {
  position: relative;
  width: 14px;
  height: 22px;
  border: 3px solid currentColor;
  border-radius: 9px;
}

.mic-glyph::before,
.mic-glyph::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: currentColor;
}

.mic-glyph::before {
  top: 21px;
  width: 3px;
  height: 8px;
}

.mic-glyph::after {
  top: 29px;
  width: 15px;
  height: 3px;
  border-radius: 2px;
}

dialog {
  width: min(420px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.dialog-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  background: #0d1511;
}

.dialog-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.55;
}

.dialog-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-dim);
  font-size: 12px;
}

.dialog-card input {
  width: 100%;
  border: 1px solid #22543b;
  border-radius: 6px;
  background: #0a100d;
  color: var(--text);
  padding: 9px 10px;
}

.primary {
  padding: 10px 12px;
  border: 1px solid var(--green);
  border-radius: 6px;
  font-weight: 800;
}

#qrVideo {
  width: 100%;
  max-height: 280px;
  border: 1px solid #22543b;
  border-radius: 6px;
  background: #000;
}

.qr-fallback {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.qr-fallback button {
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.hint {
  min-height: 18px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 380px) {
  .app-shell {
    padding-left: 8px;
    padding-right: 8px;
  }

  .topbar {
    grid-template-columns: 54px minmax(0, 1fr) auto;
    gap: 7px;
  }

  .face {
    width: 54px;
  }

  .face::before {
    left: 8px;
  }

  .face::after {
    right: 8px;
  }

  .toolbar {
    gap: 0;
  }

  .icon-button {
    width: 31px;
  }

  .glyph {
    width: 21px;
    height: 21px;
  }
}
