:root {
  --bg: #0b1220;
  --card: #111b31;
  --text: #e8eefc;
  --muted: #a9b6d6;
  --on: #86efac;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 20% 0%, #13264c, var(--bg));
  color: var(--text);
}

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 18px;
}

/* ================= Header ================= */

header {
  margin-bottom: 18px;
}

h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.sub {
  margin: 0;
  color: var(--muted);
}

/* ================= Grid ================= */

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

@media (max-width: 720px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

/* ================= Card ================= */

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.label {
  font-size: 14px;
  color: var(--muted);
}

/* ================= Icon + Text ================= */

.value {
  display: flex;
  align-items: center;
  gap: 24px;
}

.card-icon {
  width: 156px;
  height: 156px;
  flex-shrink: 0;
  opacity: 0.9;
}

.card.has-timeline .card-icon {
  width: 125px;
  height: 125px;
}

.value-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ================= Temperature ================= */

.temperature {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.temperature span:first-child {
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
}

.unit {
  font-size: 22px;
  color: var(--muted);
}

/* ================= Meta ================= */

.meta {
  font-size: 14px;
  color: var(--muted);
}

.humidity {
  font-size: 14px;
  color: var(--muted);
  margin-top: 2px;
}

/* ================= Action Buttons ================= */

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.icon-button {
  width: 64px;
  height: 32px;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  cursor: pointer;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.icon-button.is-on {
  background: rgba(134, 239, 172, 0.22);
  border-color: rgba(134, 239, 172, 0.9);
}

.icon-button.is-off {
  opacity: 0.85;
}

.button-icon {
  max-width: 40px;
  max-height: 19px;
}

/* Square variant */
.icon-button-square {
  width: 29px;
  height: 29px;
}

.icon-button-square .button-icon {
  max-width: 18px;
  max-height: 18px;
}

/* ================= Event Buttons ================= */

.event-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
  align-items: flex-start;
}

.event-button {
  height: 32px;
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  cursor: pointer;
  width: auto;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

.event-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.event-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.event-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.event-text {
  font-size: 13px;
  white-space: nowrap;
}

.event-button.is-on {
  background: rgba(134, 239, 172, 0.22);
  border-color: rgba(134, 239, 172, 0.9);
}

.event-button.is-off {
  opacity: 0.85;
}

/* ================= Day Timeline ================= */

.day-timeline {
  width: 100%;
  margin-top: 12px;
  grid-column: 1 / -1;
}

.timeline-bar {
  width: 100%;
  height: 24px;
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  overflow: visible;
  position: relative;
}

.timeline-bar::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  bottom: -2px;
  width: var(--progress-width, 0%);
  border: 2px solid rgba(255, 255, 255, 1);
  border-radius: 8px;
  pointer-events: none;
  z-index: 20;
}

.timeline-day-segment {
  position: absolute;
  top: 0;
  height: 100%;
  z-index: 1;
}

.timeline-day {
  background: linear-gradient(90deg, 
    rgba(20, 30, 80, 0.8) 0%,
    rgba(255, 200, 80, 0.6) 15%,
    rgba(255, 230, 150, 0.5) 50%,
    rgba(255, 200, 80, 0.6) 85%,
    rgba(20, 30, 80, 0.8) 100%
  );
}

.timeline-night {
  background: rgba(20, 30, 80, 0.8);
}

.timeline-progress {
  display: none;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
}

.timeline-event-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 25;
  pointer-events: none;
  transition: top 0.2s ease;
}

.timeline-event-icon {
  width: 14px;
  height: 14px;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* ================= Footer ================= */

footer {
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  align-items: center;
}

.version {
  opacity: 0.75;
}

/* ================= Time Dialog ================= */

.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.dialog {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.dialog-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dialog-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.dialog-content {
  padding: 24px 20px;
}

.dialog-content p {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 15px;
}

.time-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.time-number-input {
  width: 80px;
  padding: 12px 16px;
  font-size: 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: none;
}

.time-number-input::-webkit-inner-spin-button,
.time-number-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.time-number-input:focus {
  outline: none;
  border-color: rgba(134, 239, 172, 0.6);
  background: rgba(255, 255, 255, 0.08);
}

.time-separator {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.dialog-actions {
  padding: 16px 20px 20px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.dialog-button {
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.dialog-button-cancel {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.dialog-button-cancel:hover {
  background: rgba(255, 255, 255, 0.10);
}

.dialog-button-confirm {
  background: rgba(134, 239, 172, 0.22);
  border-color: rgba(134, 239, 172, 0.9);
  color: var(--text);
}

.dialog-button-confirm:hover {
  background: rgba(134, 239, 172, 0.30);
}

/* ================= Mobile ================= */

@media (max-width: 480px) {
  .card-icon {
    width: 132px;
    height: 132px;
  }

  .temperature span:first-child {
    font-size: 52px;
  }

  .event-button {
    height: 26px;
    padding: 3px 8px;
    width: 150px;
    max-width: 150px;
  }

  .event-icon {
    width: 16px;
    height: 16px;
  }

  .event-text {
    font-size: 12px;
  }
}
