/* The window and readout share a fixed glass surface in both app themes. */
.dev.curtain-device {
  --shade-ink: #1d2929;
  --shade-muted: #465652;
  --shade-edge: #bdc7c0;
  align-self: start;
  min-width: 0;
  padding: clamp(12px, 2vw, 19px);
  color: var(--shade-ink);
  background: linear-gradient(145deg, #f5f6f2, #e9ebe7 65%, #e1e5df);
  border: 1px solid var(--shade-edge);
  border-radius: 21px;
  box-shadow: inset 0 1px 0 #fff, 0 4px 14px #192d2910;
}
.dev.curtain-device::before { display: none; }
.dev.curtain-device.disconnected, .dev.curtain-device.unavailable { opacity: 1; filter: none; }
.dev.curtain-device.disconnected .controls, .dev.curtain-device.unavailable .controls { pointer-events: auto; }
.dev.curtain-device .top .device-history, .dev.curtain-device .top .device-name { color: var(--shade-ink); }
.dev.curtain-device .top .meta, .dev.curtain-device .wctx { color: var(--shade-muted); }
.dev.curtain-device .top .meta:empty { display: none; }
.dev.curtain-device .top .device-glyph { color: #67583a; background: #e9e5d7; border-color: #cfc7b1; }
.dev.curtain-device .top .del { color: var(--shade-muted); background: transparent; border-color: var(--shade-edge); }
.dev.curtain-device .controls:not(:empty) { padding-top: 0; margin-top: 12px; border: 0; }
.curtain-remote.shadewrap, .curtain-remote .shadectl { display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; min-width: 0; gap: 13px; }
.curtain-display {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: minmax(76px, 43%) minmax(0, 1fr); align-items: center; gap: clamp(14px, 4vw, 28px);
  padding: 14px 16px; min-height: 154px;
  border: 1px solid #202c29; border-radius: 14px;
  background: linear-gradient(125deg, #1b2827, #273a38 64%, #35443e);
  box-shadow: inset 0 1px 2px #a8b9a636, 0 1px 0 #fff;
  color: #edf6ef;
}
.curtain-display::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse at 14% 80%, #c9bb8424, transparent 64%);
}
.curtain-readout { min-width: 0; }
.curtain-display-label { color: #dcddc6; font-family: inherit; font-size: .77rem; font-weight: 600; line-height: 1.45; }
.curtain-remote .shadepct {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 5px;
  margin: 7px 0 0; color: #f3f6eb; font-family: inherit; font-variant-numeric: tabular-nums;
}
.curtain-remote .shadepct .pv { font-size: clamp(2.8rem, 9vw, 3.9rem); font-weight: 450; line-height: 1; letter-spacing: -.065em; }
.curtain-remote .shadepct .unit { margin: 0; color: #d4ded5; font-family: inherit; font-size: .86rem; font-weight: 550; line-height: 1.35; }
.curtain-remote .shadepct .unit[hidden] { display: none; }
.shade-closed { display: block; margin-top: 6px; color: #c1d0c8; font-size: .78rem; font-variant-numeric: tabular-nums; }
.shade-closed[hidden] { display: none; }
.shade-observed-at:not([hidden]) { display: block; margin-top: 4px; color: #c1d0c8; font-size: .73rem; }
.shade-period { display: block; margin-top: 12px; color: #c8d5cc; font-size: .73rem; }
.shade-period > span { display: none; align-items: center; gap: 5px; }
.shade-period .ic-svg { width: 14px; height: 14px; color: #e5c98a; }
[data-window-period="day"] .shade-period [data-period="day"],
[data-window-period="night"] .shade-period [data-period="night"] { display: inline-flex; }
.curtain-remote .shadeviz {
  box-sizing: border-box; width: 100%; height: 132px;
  border: 3px solid #7d8982; border-radius: 5px; box-shadow: 0 0 0 1px #14201f, 0 4px 10px #0b151b50;
  background: #365268; touch-action: none; contain: paint;
}
.curtain-remote .shadesky { background: #82b4d3 url('./assets/panel/ambient/clouds.jpg') center 56% / cover; }
.curtain-remote .shadesky::before {
  content: ""; position: absolute; inset: 0; opacity: 0;
  background: #12233e url('./assets/panel/ambient/night.jpg') center 55% / cover;
  transition: opacity .65s ease;
}
[data-window-period="night"] .curtain-remote .shadesky::before { opacity: 1; }
.curtain-remote .shadesky::after {
  content: ""; inset: 0; width: auto; height: auto; border-radius: 0;
  background: linear-gradient(90deg, transparent calc(50% - 1px), #48525099 50%, transparent calc(50% + 1px));
  box-shadow: inset 0 1px 5px #14232a66;
}
.curtain-remote .shadefabric {
  box-sizing: border-box; height: 100%;
  border-bottom: 3px solid #958b75;
  background: linear-gradient(90deg, #171a1629, transparent 19% 75%, #171a161a),
    repeating-linear-gradient(0deg, #817969 0 1px, #aa9f89 2px, #c2b9a3 4px, #b3aa94 5px);
  box-shadow: 0 3px 6px #18211f55;
  transform: translateY(calc(0% - var(--shade-travel, 0%)));
  transition: transform var(--dur-slow) var(--ease-standard);
}
.curtain-remote .shadefabric::before, .curtain-remote .shadefabric::after { display: none; }
.curtain-remote .shadeviz[data-style="roller"][role="slider"] .shadefabric::after {
  display: block; left: 50%; bottom: 0; width: 22px; height: 2px; border: 0;
  background: #e7dfce; border-radius: 2px; transform: translateX(-50%);
}
.curtain-remote .shadeviz:not([data-style="roller"]) .shadefabric {
  width: 100%; height: 100%; transform: translateX(calc(0% - var(--shade-travel, 0%)));
  transition: transform var(--dur-slow) var(--ease-standard);
  background: repeating-linear-gradient(90deg, #979079, #bdb49c 5px, #d2c8b0 7px, #a09984 8px);
}
.curtain-remote .shadeviz[data-style="split"] .shadefabric { width: 50%; }
.curtain-remote .shadeviz[data-style="right"] .shadefabric,
.curtain-remote .shadeviz[data-style="split"] .sf-r { transform: translateX(var(--shade-travel, 0%)); }
.curtain-remote .shadeviz.drag .shadefabric { transition: none; }
.curtain-remote .shadeviz[data-known="false"] { border: 1px dashed #90a69b; box-shadow: none; cursor: default; touch-action: auto; }
.curtain-remote .shadeviz[role="img"] { cursor: default; touch-action: auto; }
.curtain-remote .shadeviz[data-known="false"] .shadefabric { visibility: hidden; }
.curtain-remote .shadeviz[data-known="false"] .shadesky { filter: blur(4px); opacity: .45; }
.curtain-remote .shadeviz[data-known="false"]::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(135deg, transparent 0 9px, #cad9cf16 9px 10px);
}
.curtain-remote .curtain-control-set { display: grid; gap: 6px; min-width: 0; }
.curtain-field-label { color: var(--shade-muted); font-size: .74rem; font-weight: 600; line-height: 1.45; letter-spacing: .015em; }
.curtain-remote .seg { display: grid; gap: 4px; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.curtain-remote .seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 0; min-height: 46px; padding: 7px 4px; touch-action: manipulation; overflow-wrap: anywhere;
  color: var(--shade-ink); border: 1px solid #bdc8be; border-radius: 10px;
  background: #f3f5f0; box-shadow: inset 0 1px 0 #fff;
  font: inherit; font-size: .85rem; font-weight: 600; line-height: 1.35;
}
.curtain-remote .curtain-drive [data-drive="stop"] { color: #f4f8ef; background: #2d443c; border-color: #233c34; box-shadow: inset 0 1px 0 #ffffff18; }
.curtain-action-icon { flex: none; display: inline-block; width: 8px; height: 8px; }
.curtain-drive [data-drive="stop"] i { background: currentColor; border-radius: 1px; }
.curtain-drive [data-drive="open"] i, .curtain-drive [data-drive="close"] i { border: solid currentColor; border-width: 1.75px 1.75px 0 0; transform: translateY(2px) rotate(-45deg); }
.curtain-drive [data-drive="close"] i { transform: translateY(-2px) rotate(135deg); }
.curtain-remote .curtain-position { padding: 3px; background: #d9dfd9; border: 1px solid #c3ccc4; border-radius: 12px; }
.curtain-remote .curtain-position button { min-height: 44px; background: transparent; border-color: transparent; box-shadow: none; }
.curtain-remote .curtain-position button[aria-pressed="true"] { color: #172f2b; background: #fafbf8; border-color: #b4c2b9; box-shadow: 0 1px 3px #20352d24; }
.curtain-remote[data-style="left"] [data-drive="open"] i, .curtain-remote[data-style="right"] [data-drive="close"] i {
  transform: rotate(-135deg);
}
.curtain-remote[data-style="right"] [data-drive="open"] i, .curtain-remote[data-style="left"] [data-drive="close"] i {
  transform: rotate(45deg);
}
.curtain-remote .curtain-guidance { margin: -3px 0 0; color: var(--shade-muted); font-size: .76rem; line-height: 1.45; }
.curtain-remote .curtain-guidance[hidden] { display: none; }
.curtain-calibration:not([hidden]) { display: grid; justify-items: start; gap: 4px; }
.curtain-calibration button { min-height: 44px; max-width: 100%; padding: 6px 12px; color: var(--shade-ink); border: 1px solid var(--shade-edge); border-radius: 10px; white-space: normal; }
.curtain-calibration small { color: var(--shade-muted); line-height: 1.4; }
.curtain-calibration small:empty { display: none; }
.curtain-calibration details { width: 100%; font-size: .77rem; color: var(--shade-muted); }
.curtain-calibration summary { cursor: pointer; align-content: center; min-height: 44px; }
.curtain-calibration .observed-choices { display: flex; flex-wrap: wrap; gap: 4px; }
.curtain-calibration .observed-choices button { font: inherit; background: transparent; }
.curtain-remote .autorow { margin: 0; border-top: 1px solid #c5cdc4; padding-top: 7px; min-height: 46px; }
.curtain-remote .autorow .txt { color: var(--shade-ink); font: inherit; font-size: .84rem; font-weight: 600; }
.curtain-remote .autorow .txt .ic-svg { color: #85692d; }
.curtain-remote .seg button:disabled { color: #59655f; background: #e1e5de; border-color: #cbd2c9; box-shadow: none; cursor: default; }
.curtain-remote .seg button:focus-visible, .curtain-remote .shadeviz:focus-visible { outline: 2px solid #00827c; outline-offset: 2px; }
.room-roller-pair {
  display: grid; grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr));
  container: roller-pair / inline-size; align-items: start; gap: clamp(6px, 1.2vw, 12px); min-width: 0;
}
.room-roller-pair > .dev {
  display: grid; grid-row: span 2; grid-template-rows: subgrid;
  row-gap: 0; margin: 0; align-self: stretch;
}
.room-roller-pair .curtain-remote .shadeviz { height: auto; aspect-ratio: 1.8; }
/* On a phone the two windows still share a row. Controls stack inside each
   narrower remote when three touch targets cannot fit alongside one another. */
@container roller-pair (max-width: 600px) {
  .room-roller-pair .curtain-display { grid-template-columns: minmax(0, 1fr); gap: 7px; padding: 8px; }
  .room-roller-pair .curtain-display-label { font-size: .72rem; }
  .room-roller-pair .shadepct .pv { font-size: 2rem; }
  .room-roller-pair .shadepct { margin-top: 3px; }
  .room-roller-pair .shade-closed, .room-roller-pair .shade-period { margin-top: 3px; }
  .room-roller-pair .device-glyph { display: none; }
  .room-roller-pair .dev .name { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .room-roller-pair .top { gap: 3px; }
  .room-roller-pair .curtain-remote, .room-roller-pair .curtain-remote .shadectl { gap: 8px; }
  .room-roller-pair .curtain-remote .seg { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(min(100%, 44px), 1fr)); gap: 2px; }
  .room-roller-pair .curtain-remote .seg button { min-height: 44px; padding-inline: 2px; overflow-wrap: anywhere; }
  .room-roller-pair .curtain-drive .curtain-action-icon { display: none; }
  .room-roller-pair .autorow { flex-wrap: wrap; gap: 4px; }
  .room-roller-pair .autorow .txt { min-width: 0; overflow-wrap: anywhere; }
}
@container roller-pair (max-width: 350px) {
  .room-roller-pair .curtain-remote .seg { grid-template-columns: minmax(0, 1fr); }
}
@media (hover: hover) {
  .curtain-remote .seg button:not(:disabled):hover { border-color: #638175; }
}
.calm-ui .curtain-remote .shadeviz .shadefabric, .calm-ui .curtain-remote .shadesky::before { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .curtain-remote .shadeviz[data-style] .shadefabric, .curtain-remote .shadesky::before { transition: none; }
}
@media (forced-colors: active) {
  .curtain-remote .seg button { border-color: ButtonText; }
  .curtain-remote .seg button[aria-pressed="true"] { outline: 2px solid Highlight; outline-offset: -3px; }
  .curtain-action-icon { forced-color-adjust: none; }
}
