:root {
  color-scheme: light;
  --wall: #c97858;
  --wall-shadow: #9f4f3e;
  --wood: #9a5a38;
  --wood-dark: #5e3428;
  --paper: #fff2d2;
  --ink: #40251f;
  --muted: #76544b;
  --accent: #4f8f7b;
  --sky: #9fd7e8;
  --horizon: #6ea77d;
  --window-frame: #6f3f2d;
  --lamp: #ffd36f;
  --lamp-glow: rgba(255, 201, 104, 0.34);
  --font-family: "Trebuchet MS", "Microsoft YaHei", sans-serif;
  font-family: var(--font-family);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--wall);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cabin {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-rows: minmax(420px, 62vh) minmax(230px, 38vh);
  background:
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(var(--wall), var(--wall-shadow));
}

.wall {
  position: relative;
  padding: clamp(18px, 4vw, 44px);
}

.window {
  position: absolute;
  left: clamp(18px, 5vw, 72px);
  top: clamp(18px, 5vw, 54px);
  width: min(34vw, 340px);
  min-width: 220px;
  aspect-ratio: 1.18;
  border: 14px solid var(--window-frame);
  border-radius: 8px;
  box-shadow: inset 0 0 0 5px rgba(255,255,255,0.2), 8px 12px 0 rgba(63, 35, 28, 0.16);
  overflow: hidden;
  background: var(--sky);
}

.sky {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(var(--sky), #e3f3df);
}

.sun,
.moon,
.cloud,
.star,
.rain,
.snow,
.hills {
  position: absolute;
  display: block;
}

.sun {
  width: 54px;
  height: 54px;
  right: 16%;
  top: 16%;
  border-radius: 50%;
  background: #ffe28a;
  box-shadow: 0 0 0 10px rgba(255, 226, 138, 0.22);
}

.moon {
  display: none;
  width: 46px;
  height: 46px;
  right: 18%;
  top: 14%;
  border-radius: 50%;
  background: #f6edd0;
  box-shadow: -10px 3px 0 #6c7790 inset;
}

.hills {
  left: -5%;
  bottom: -10%;
  width: 110%;
  height: 35%;
  background:
    radial-gradient(80% 90% at 20% 90%, var(--horizon) 0 50%, transparent 51%),
    radial-gradient(80% 90% at 72% 90%, #5d936f 0 52%, transparent 53%);
}

.todo-board,
.calendar-card,
.clock-card {
  border: 4px solid var(--wood-dark);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 8px 10px 0 rgba(63, 35, 28, 0.18);
}

.todo-board {
  position: absolute;
  left: 50%;
  top: 11%;
  display: flex;
  flex-direction: column;
  width: min(34vw, 390px);
  min-width: 280px;
  max-height: min(48vh, 390px);
  transform: translateX(-50%);
  padding: 22px;
}

.board-string {
  position: absolute;
  left: 50%;
  top: -42px;
  width: 120px;
  height: 42px;
  border-left: 3px solid var(--wood-dark);
  border-right: 3px solid var(--wood-dark);
  border-top: 3px solid var(--wood-dark);
  transform: translateX(-50%) rotate(45deg);
}

.todo-board h1 {
  margin: 0 0 14px;
  font-size: 1.55rem;
  letter-spacing: 0;
}

.todo-form {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
}

.todo-form input {
  min-width: 0;
  border: 3px solid var(--wood-dark);
  border-radius: 6px;
  padding: 10px;
  background: #fff9e8;
  color: var(--ink);
}

.todo-form button,
.todo-delete,
.todo-check {
  border: 3px solid var(--wood-dark);
  border-radius: 6px;
  background: var(--accent);
  color: #fff9e8;
  cursor: pointer;
}

.todo-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  max-height: min(22vh, 180px);
  margin: 14px 0 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0;
  padding-right: 4px;
  list-style: none;
}

.calendar-card {
  position: absolute;
  right: clamp(24px, 7vw, 90px);
  top: 19%;
  width: min(22vw, 220px);
  min-width: 160px;
  padding: 18px;
  text-align: center;
}

.calendar-year,
.calendar-weekday {
  margin: 0;
  color: var(--muted);
}

.calendar-date {
  margin: 10px 0;
  font-size: 2rem;
  font-weight: 700;
}

.desk {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(20px, 8vw, 100px) 58px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(#b87446, var(--wood));
  border-top: 12px solid var(--wood-dark);
}

.clock-card {
  width: min(38vw, 360px);
  min-width: 250px;
  padding: 20px;
}

.clock-label,
.weather-line,
.weather-detail {
  margin: 0;
}

#clock-time {
  display: block;
  margin: 6px 0 12px;
  font-size: clamp(2rem, 5vw, 3.75rem);
  font-weight: 700;
  line-height: 1;
}

.weather-line {
  font-weight: 700;
}

.weather-detail {
  margin-top: 4px;
  color: var(--muted);
}

.lamp {
  position: relative;
  width: 180px;
  height: 210px;
  padding: 0;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.lamp-shade {
  position: absolute;
  left: 38px;
  top: 14px;
  width: 106px;
  height: 62px;
  background: var(--lamp);
  clip-path: polygon(22% 0, 78% 0, 100% 100%, 0 100%);
  border: 4px solid var(--wood-dark);
}

.lamp-neck {
  position: absolute;
  left: 84px;
  top: 78px;
  width: 14px;
  height: 80px;
  background: var(--wood-dark);
}

.lamp-base {
  position: absolute;
  left: 48px;
  bottom: 14px;
  width: 86px;
  height: 28px;
  border-radius: 50% 50% 8px 8px;
  background: var(--wood-dark);
}

.lamp-glow {
  position: absolute;
  display: none;
  left: -60px;
  top: 58px;
  width: 300px;
  height: 200px;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 0%, var(--lamp-glow), transparent 70%);
}

.lamp.is-on .lamp-glow {
  display: block;
}

.icp-footer {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 5;
  padding: 6px 12px;
  border: 3px solid var(--wood-dark);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 4px 5px 0 rgba(63, 35, 28, 0.16);
}

.icp-footer a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
}

@media (min-width: 861px) and (max-width: 1199px) {
  .window {
    width: min(27vw, 320px);
  }
}

.cloud {
  width: 82px;
  height: 30px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 22px -10px 0 rgba(255, 255, 255, 0.88), 46px 0 0 rgba(255, 255, 255, 0.88);
  animation: cloud-drift 11s ease-in-out infinite alternate;
}

.cloud-one {
  left: 18%;
  top: 24%;
}

.cloud-two {
  right: 18%;
  top: 38%;
  transform: scale(0.75);
  animation-duration: 14s;
}

.star {
  display: none;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff7cc;
}

.star-one { left: 18%; top: 18%; }
.star-two { left: 42%; top: 28%; }
.star-three { right: 28%; top: 34%; }

.rain {
  display: none;
  width: 3px;
  height: 48px;
  border-radius: 999px;
  background: rgba(210, 236, 255, 0.76);
  transform: rotate(12deg);
  animation: rain-fall 0.72s linear infinite;
}

.rain-one { left: 24%; top: -20%; }
.rain-two { left: 52%; top: -10%; animation-delay: 0.2s; }
.rain-three { left: 78%; top: -26%; animation-delay: 0.4s; }

.snow {
  display: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.9);
  animation: snow-drift 4s linear infinite;
}

.snow-one { left: 20%; top: -8%; }
.snow-two { left: 55%; top: -14%; animation-delay: 1s; }
.snow-three { left: 80%; top: -4%; animation-delay: 2s; }

.is-night {
  color-scheme: dark;
  --wall: #4c3842;
  --wall-shadow: #2f2431;
  --paper: #efe0ba;
  --ink: #2b201c;
  --muted: #6f564f;
  --sky: #34435f;
  --horizon: #263b42;
  --lamp-glow: rgba(255, 198, 95, 0.45);
}

.is-night .sky {
  background: linear-gradient(#202b46, var(--sky));
}

.is-night .sun {
  display: none;
}

.is-night .moon,
.is-night .star {
  display: block;
}

.weather-sunny {
  --accent: #4f8f7b;
  --sky: #9fd7e8;
  --horizon: #74aa76;
}

.weather-cloudy {
  --accent: #667f8f;
  --sky: #aabccd;
  --horizon: #78907c;
}

.weather-cloudy .sun {
  opacity: 0.38;
}

.weather-rainy {
  --accent: #4f6f86;
  --sky: #708fa4;
  --horizon: #516d65;
}

.weather-rainy .rain {
  display: block;
}

.weather-rainy .cloud {
  background: rgba(226, 232, 235, 0.9);
  box-shadow: 22px -10px 0 rgba(226, 232, 235, 0.9), 46px 0 0 rgba(226, 232, 235, 0.9);
}

.weather-snowy {
  --accent: #7589a4;
  --sky: #b8c9d8;
  --horizon: #d8e6e8;
}

.weather-snowy .snow {
  display: block;
}

.weather-unknown {
  --accent: #706d9f;
  --sky: #9ab0c8;
  --horizon: #cbdce3;
}

.is-night.weather-sunny {
  --accent: #6aa692;
  --sky: #34435f;
  --horizon: #263b42;
}

.is-night.weather-cloudy {
  --accent: #7b8e9c;
  --sky: #303a50;
  --horizon: #25383d;
}

.is-night.weather-rainy {
  --accent: #6f8ba0;
  --sky: #29394f;
  --horizon: #203333;
}

.is-night.weather-snowy {
  --accent: #91a1b8;
  --sky: #3a465d;
  --horizon: #4f5e62;
}

.is-night.weather-unknown {
  --accent: #8b88bf;
  --sky: #333d5d;
  --horizon: #34414b;
}

@keyframes cloud-drift {
  from { margin-left: -8px; }
  to { margin-left: 10px; }
}

@keyframes rain-fall {
  from { transform: translate(0, -70px) rotate(12deg); opacity: 0; }
  20% { opacity: 1; }
  to { transform: translate(18px, 250px) rotate(12deg); opacity: 0; }
}

@keyframes snow-drift {
  from { transform: translate(0, -30px) rotate(0deg); opacity: 0; }
  20% { opacity: 1; }
  to { transform: translate(24px, 245px) rotate(90deg); opacity: 0; }
}

@media (max-width: 860px) {
  .cabin {
    grid-template-rows: auto auto;
  }

  .wall {
    display: grid;
    gap: 18px;
    padding: 18px;
  }

  .window,
  .todo-board,
  .calendar-card {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    width: 100%;
    min-width: 0;
    transform: none;
  }

  .window {
    max-width: 420px;
    justify-self: start;
  }

  .todo-board {
    max-height: none;
  }

  .board-string {
    display: none;
  }

  .desk {
    flex-direction: column;
    align-items: stretch;
    padding: 20px 18px 70px;
  }

  .clock-card {
    width: 100%;
    min-width: 0;
  }

  .lamp {
    align-self: end;
    width: 150px;
    height: 180px;
  }

  .lamp-shade {
    left: 32px;
    width: 90px;
  }

  .lamp-neck {
    left: 70px;
    height: 65px;
  }

  .lamp-base {
    left: 38px;
  }

  .icp-footer {
    width: calc(100% - 28px);
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

.todo-item {
  display: grid;
  grid-template-columns: 30px 1fr 30px;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px;
  border: 2px solid rgba(94, 52, 40, 0.25);
  border-radius: 6px;
  background: rgba(255, 249, 232, 0.7);
}

.todo-check,
.todo-delete {
  width: 30px;
  height: 30px;
  padding: 0;
  line-height: 1;
}

.todo-delete {
  background: #a34740;
}

.todo-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.todo-item.is-complete .todo-text {
  color: var(--muted);
  text-decoration: line-through;
}

.todo-empty {
  padding: 10px;
  color: var(--muted);
  border: 2px dashed rgba(94, 52, 40, 0.32);
  border-radius: 6px;
  text-align: center;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px #f6d36e;
}

.todo-form button:hover,
.todo-check:hover,
.todo-delete:hover {
  filter: brightness(1.04);
}
