:root {
  color-scheme: light;
  --bg: #f3efe7;
  --bg-strong: #ece6dd;
  --surface: rgba(247, 245, 240, 0.78);
  --surface-strong: rgba(236, 240, 238, 0.92);
  --surface-inverse: #111111;
  --text: #111111;
  --text-muted: #676a6e;
  --line: rgba(17, 17, 17, 0.08);
  --accent: #0b7d8c;
  --accent-soft: rgba(11, 125, 140, 0.12);
  --success: #0d8b57;
  --danger: #b24f56;
  --shadow-xl: 0 24px 60px rgba(32, 35, 38, 0.12);
  --shadow-lg: 0 16px 40px rgba(32, 35, 38, 0.1);
  --shadow-md: 0 10px 24px rgba(32, 35, 38, 0.08);
  --radius-xl: 34px;
  --radius-lg: 28px;
  --radius-md: 22px;
  --radius-sm: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  display: flex;
  justify-content: center;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), transparent 34%),
    radial-gradient(circle at top right, rgba(11, 125, 140, 0.08), transparent 30%),
    linear-gradient(180deg, #fbfaf7 0%, var(--bg) 42%, var(--bg-strong) 100%);
  color: var(--text);
  font-family: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.52;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  padding: 14px 16px;
  outline: none;
  color: var(--text);
}

input:focus {
  border-color: rgba(11, 125, 140, 0.45);
  box-shadow: 0 0 0 4px rgba(11, 125, 140, 0.12);
}

.app-shell {
  position: relative;
  isolation: isolate;
  width: min(100%, 440px);
  min-height: 100vh;
  padding: calc(12px + var(--safe-top)) 14px calc(92px + var(--safe-bottom));
}

.screen {
  display: flex;
  min-height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 104px);
  flex-direction: column;
  gap: 14px;
}

.screen--detail {
  gap: 10px;
}

.home-header,
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(160deg, #19c0f3 0%, #0586b6 100%);
  color: #ffffff;
  font-size: 0.98rem;
  font-weight: 800;
  box-shadow: var(--shadow-md);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--text-muted);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.title {
  margin: 0;
  font-size: clamp(1.7rem, 6vw, 2.35rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.detail-title {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.05rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
  text-align: center;
}

.detail-header__center {
  flex: 1;
  text-align: center;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.96rem;
  line-height: 1.6;
}

.icon-button {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
}

.icon-button svg,
.detail-icon-button svg,
.control-fab svg,
.sheet-option__icon svg,
.blind-pull svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

.detail-icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--text);
}

.section-copy {
  margin-top: -8px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.device-card {
  display: flex;
  min-height: 126px;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  padding: 18px 16px;
  text-align: left;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.device-card:active {
  transform: scale(0.985);
  box-shadow: var(--shadow-md);
}

.device-card__top,
.device-card__body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.device-card__icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--text);
}

.device-card__icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
}

.device-card__name {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.device-card__meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
}

.status-chip--moving {
  background: rgba(11, 125, 140, 0.12);
  color: var(--accent);
}

.status-chip--offline {
  background: rgba(178, 79, 86, 0.12);
  color: var(--danger);
}

.status-chip--online {
  background: rgba(13, 139, 87, 0.12);
  color: var(--success);
}

.fab {
  position: fixed;
  right: max(14px, calc((100vw - 440px) / 2 + 14px));
  bottom: calc(18px + var(--safe-bottom));
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.34);
  color: var(--text);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(14px);
}

.fab svg {
  width: 28px;
  height: 28px;
  stroke: currentColor;
}

.loading-shell,
.empty-shell {
  display: grid;
  min-height: 50vh;
  place-items: center;
  text-align: center;
  color: var(--text-muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 98px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  padding: 13px 18px;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  box-shadow: var(--shadow-md);
}

.detail-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pill-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.hero-card {
  position: relative;
  margin-top: 4px;
  padding: 0 10px;
}

.blind-frame {
  position: relative;
  height: min(39vh, 370px);
  min-height: 260px;
  overflow: hidden;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(238, 234, 226, 0.95) 0%, rgba(243, 239, 231, 0.98) 100%);
  padding: 14px;
  box-shadow: var(--shadow-xl);
}

.blind-window {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(180deg, #e6eff4 0%, #bfe2ee 34%, #a8d7dc 36%, #b9d5a1 36%, #9ec17e 64%, #5e9c55 100%);
  box-shadow: inset 0 8px 18px rgba(17, 17, 17, 0.08);
}

.blind-window::before {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg,
      rgba(255, 255, 255, 0.48) 0 8%,
      transparent 8% 21%,
      rgba(255, 255, 255, 0.14) 21% 23%,
      transparent 23% 77%,
      rgba(255, 255, 255, 0.14) 77% 79%,
      transparent 79% 92%,
      rgba(255, 255, 255, 0.42) 92%);
  content: "";
  pointer-events: none;
}

.blind-window::after {
  position: absolute;
  inset: auto 0 0;
  height: 40%;
  background:
    radial-gradient(circle at 20% 40%, rgba(255, 255, 255, 0.2), transparent 24%),
    radial-gradient(circle at 70% 18%, rgba(255, 208, 92, 0.2), transparent 16%),
    linear-gradient(180deg, transparent, rgba(17, 17, 17, 0.06));
  content: "";
  pointer-events: none;
}

.blind-rail {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 22px;
  background: linear-gradient(180deg, rgba(222, 217, 209, 0.95), rgba(183, 178, 171, 0.88));
  box-shadow: 0 5px 10px rgba(17, 17, 17, 0.12);
  z-index: 2;
}

.blind-scene {
  position: absolute;
  inset: 0;
}

.blind-scene__sun {
  position: absolute;
  right: 22%;
  top: 13%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 112, 0.92) 0%, rgba(255, 214, 112, 0.24) 68%, transparent 72%);
  filter: blur(0.2px);
}

.blind-scene__hill {
  position: absolute;
  left: -8%;
  right: -8%;
  border-radius: 50%;
}

.blind-scene__hill--far {
  bottom: 22%;
  height: 26%;
  background: #9fc484;
}

.blind-scene__hill--near {
  bottom: -10%;
  height: 34%;
  background: #2f7642;
}

.blind-scene__tree,
.blind-scene__tree::before,
.blind-scene__tree::after {
  position: absolute;
}

.blind-scene__tree {
  bottom: 16%;
  width: 12px;
  height: 60px;
  background: #2f7642;
  border-radius: 999px;
}

.blind-scene__tree::before,
.blind-scene__tree::after {
  left: 50%;
  transform: translateX(-50%);
  content: "";
}

.blind-scene__tree::before {
  bottom: 14px;
  width: 30px;
  height: 46px;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  background: #3f8a48;
}

.blind-scene__tree::after {
  bottom: 28px;
  width: 24px;
  height: 38px;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  background: #2f7642;
}

.blind-scene__tree--one {
  left: 6%;
}

.blind-scene__tree--two {
  left: 14%;
  height: 72px;
}

.blind-scene__tree--three {
  left: 22%;
}

.blind-scene__house {
  position: absolute;
  bottom: 30%;
  width: 40px;
  height: 32px;
  background: #f1cb6a;
  box-shadow: inset 0 -10px rgba(0, 0, 0, 0.06);
}

.blind-scene__house::before,
.blind-scene__house::after {
  position: absolute;
  content: "";
}

.blind-scene__house::before {
  left: -2px;
  right: -2px;
  bottom: 100%;
  height: 18px;
  background: #3f7e8a;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

.blind-scene__house::after {
  left: 50%;
  bottom: 0;
  width: 8px;
  height: 16px;
  transform: translateX(-50%);
  background: #ffffff99;
}

.blind-scene__house--main {
  right: 14%;
}

.blind-scene__house--small {
  right: 28%;
  bottom: 27%;
  transform: scale(0.8);
  transform-origin: bottom right;
}

.blind-slats {
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  height: calc(var(--blind-cover, 52) * 1%);
  min-height: 12%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 246, 244, 0.96)),
    repeating-linear-gradient(
      to bottom,
      rgba(35, 118, 145, 0.9) 0 2px,
      rgba(255, 255, 255, 0.72) 2px 14px
    );
  box-shadow:
    inset 0 8px 12px rgba(17, 17, 17, 0.08),
    0 20px 22px rgba(17, 17, 17, 0.08);
  transition: height 140ms linear;
  z-index: 1;
}

.blind-slats::after {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg,
      rgba(255, 255, 255, 0.32) 0 18%,
      rgba(255, 255, 255, 0.05) 18% 73%,
      rgba(255, 255, 255, 0.38) 73% 100%);
  content: "";
}

.blind-slats::before {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 6px;
  background: linear-gradient(180deg, rgba(98, 107, 114, 0.35), rgba(73, 79, 84, 0.55));
  content: "";
  box-shadow: 0 6px 10px rgba(17, 17, 17, 0.14);
}

.hero-slider-track {
  position: absolute;
  inset: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 3;
}

.hero-slider-track__line,
.hero-slider-track__active {
  display: none;
}

.blind-pull {
  position: absolute;
  left: 50%;
  top: clamp(42px, calc(18px + (var(--blind-cover, 52) * 1%)), calc(100% - 30px));
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #7c7f83;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, -50%);
  transition: top 140ms linear, transform 180ms ease, box-shadow 180ms ease;
  pointer-events: none;
}

.hero-slider-track:focus-visible {
  outline: none;
}

.hero-slider-track:focus-visible .blind-pull {
  box-shadow:
    var(--shadow-lg),
    0 0 0 6px rgba(11, 125, 140, 0.18);
}

.blind-pull svg {
  width: 18px;
  height: 18px;
}

.hero-slider-track--disabled {
  opacity: 0.56;
}

.detail-footer {
  display: flex;
  flex-direction: column;
  gap: 26px;
  margin-top: auto;
  padding-top: 4px;
}

.control-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.control-stack--settings {
  align-self: center;
}

.control-fab {
  display: grid;
  width: min(23vw, 82px);
  height: min(23vw, 82px);
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-lg);
}

.control-fab--settings {
  width: 72px;
  height: 72px;
}

.control-fab--settings svg {
  width: 24px;
  height: 24px;
}

.control-fab--active {
  background: var(--surface-inverse);
  color: #ffffff;
}

.control-stack__label {
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 500;
}

.control-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.control-fab:not(:disabled):active,
.action-button:not(:disabled):active,
.action-chip:not(:disabled):active {
  transform: scale(0.98);
}

.control-fab:disabled,
.action-button:disabled,
.action-chip:disabled {
  box-shadow: none;
}

.control-fab:disabled + .control-stack__label {
  color: rgba(17, 17, 17, 0.34);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.18);
  backdrop-filter: blur(8px);
  transition: opacity 220ms ease;
  z-index: 40;
}

.sheet {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 0;
  width: min(100%, 430px);
  padding: 0 14px calc(18px + var(--safe-bottom));
  transform: translate(-50%, var(--sheet-offset, 0px));
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 41;
}

.sheet--dragging {
  transition: none;
}

.sheet__card {
  max-height: min(78vh, 720px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 34px 34px 0 0;
  background: rgba(252, 250, 245, 0.96);
  padding: 10px 18px 26px;
  box-shadow: 0 -24px 60px rgba(17, 17, 17, 0.16);
}

.sheet__top {
  padding: 4px 0 6px;
  touch-action: none;
}

.sheet__grabber {
  width: 54px;
  height: 5px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.12);
}

.sheet__title {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.04em;
}

.sheet__subtitle {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.55;
}

.sheet-section {
  margin-top: 22px;
  border-radius: 24px;
  background: rgba(241, 239, 234, 0.88);
  padding: 16px;
}

.sheet-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.sheet-section__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.sheet-section__text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.sheet-options {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.sheet-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  padding: 16px 18px;
  text-align: left;
}

.sheet-option__copy strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
  letter-spacing: -0.03em;
}

.sheet-option__copy span {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.sheet-option__icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: rgba(17, 17, 17, 0.05);
}

.rename-form {
  display: grid;
  gap: 12px;
}

.inline-actions,
.stack-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stack-actions {
  flex-direction: column;
}

.action-chip,
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  border-radius: 999px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.82);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.04);
}

.action-button--primary {
  background: var(--surface-inverse);
  color: #ffffff;
}

.action-button--ghost {
  background: rgba(17, 17, 17, 0.05);
}

.manual-grid,
.diagnostics-grid {
  display: grid;
  gap: 12px;
}

.jog-presets-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.jog-preset-button {
  min-height: 72px;
  padding: 12px 8px;
  font-size: 1rem;
  letter-spacing: -0.03em;
}

.manual-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.diagnostics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-label {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.diagnostic-card {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  padding: 14px;
}

.diagnostic-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.diagnostic-card span {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  width: min(calc(100% - 28px), 390px);
  transform: translateX(-50%);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(17, 17, 17, 0.86);
  color: #ffffff;
  box-shadow: var(--shadow-lg);
  z-index: 30;
  backdrop-filter: blur(18px);
}

.toast--error {
  background: rgba(154, 53, 61, 0.92);
}

.toast--success {
  background: rgba(11, 103, 67, 0.9);
}

.detail-alert {
  border-radius: 18px;
  background: rgba(178, 79, 86, 0.1);
  padding: 14px 16px;
  color: #87454c;
  font-size: 0.92rem;
  line-height: 1.5;
}

.detail-alert-slot {
  min-height: 82px;
}

.detail-alert--placeholder {
  visibility: hidden;
}

.muted-line {
  color: var(--text-muted);
}

@media (max-width: 360px) {
  .device-grid,
  .jog-presets-grid,
  .manual-grid,
  .diagnostics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .blind-frame {
    min-height: 308px;
  }

  .control-row {
    gap: 8px;
  }

  .control-fab {
    width: 74px;
    height: 74px;
  }
}
