:root {
  --bg-1: #eef3ff;
  --bg-2: #f8fbff;
  --text: #17304f;
  --muted: #5c7394;
  --brand: #2f80ed;
  --danger: #d94b4b;
  --glass-bg: rgba(255, 255, 255, 0.44);
  --glass-border: rgba(255, 255, 255, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, #ffffff 0%, var(--bg-1) 38%, var(--bg-2) 100%);
}

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 10px 30px rgba(47, 128, 237, 0.1);
}

.app-shell {
  min-height: 100vh;
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 14px calc(86px + env(safe-area-inset-bottom));
}

.top-bar {
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.top-bar h1 { margin: 0; font-size: clamp(20px, 2.8vw, 28px); }
.top-bar p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
body.mine-mode .top-bar { display: none; }

.content {
  display: grid;
  gap: 12px;
}

.page { display: none; gap: 12px; }
.page.active { display: grid; }

.card {
  border-radius: 20px;
  padding: 14px;
}
.card h2 {
  margin: 0;
  font-size: 18px;
}

.card-title-row, .schedule-head, .modal-header, .weather-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.icon-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { min-width: 38px; padding: 8px 10px; font-size: 18px; line-height: 1; }
.city-btn {
  border: none;
  background: rgba(47, 128, 237, 0.12);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  vertical-align: middle;
}

.weather-actions {
  margin-top: 10px;
  flex-wrap: nowrap;
}
.weather-actions input[type="text"] {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #c9dbf6;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  font-size: 14px;
}

.pill-btn {
  border: none;
  border-radius: 999px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #3a8dff, #4da4ff);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.pill-btn:hover { filter: brightness(1.03); }
.pill-btn.ghost {
  background: rgba(25, 60, 108, 0.12);
  color: var(--text);
}
.pill-btn.danger { background: var(--danger); }

.weather-info {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.status-text { margin-top: 8px; color: var(--muted); min-height: 0; }
.status-text:empty { display: none; }
.weather-chip {
  border-radius: 14px;
  padding: 10px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.85), rgba(226, 240, 255, 0.62));
  border: 1px solid rgba(180, 210, 245, 0.6);
}
.weather-chip strong { display: block; font-size: 12px; color: var(--muted); }
.weather-chip .w-icon { margin-right: 6px; }

.week-badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(47, 128, 237, 0.14);
}

.course-list { margin-top: 10px; display: grid; gap: 8px; }
.course-item {
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(190, 214, 240, 0.6);
  touch-action: pan-y;
  user-select: none;
}
.course-item .title { font-weight: 700; }
.course-item .desc { color: var(--muted); margin-top: 4px; font-size: 13px; }
.course-item .day-tag {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.grid {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.grid-item {
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  min-height: 92px;
  padding: 10px;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  display: grid;
  align-content: center;
}
.grid-title { display: block; font-weight: 700; }
.grid-sub { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(720px, calc(100vw - 18px));
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 999px;
  padding: 6px;
  z-index: 5;
}
.nav-btn {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 12px;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}
.nav-btn.active {
  background: rgba(47, 128, 237, 0.17);
  color: var(--text);
  font-weight: 700;
}

.embed-frame {
  width: 100%;
  height: 62vh;
  border: none;
  border-radius: 14px;
  background: #fff;
}

.tool-panel { display: grid; gap: 10px; }
.inline-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
}
.list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.list-item {
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.65);
}
.muted { color: var(--muted); font-size: 13px; }
.clock {
  text-align: center;
  font-size: clamp(32px, 7vw, 76px);
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.note-photo {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
  margin-top: 8px;
}
.hidden { display: none; }
.inline-editor {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.workspace-body {
  margin-top: 10px;
  min-height: 220px;
}
.tool-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tool-tab.active {
  background: linear-gradient(135deg, #3a8dff, #4da4ff);
  color: #fff;
}
.lap-list {
  margin: 0;
  padding-left: 18px;
}
.landscape-clock {
  writing-mode: horizontal-tb;
  font-size: clamp(44px, 9vw, 110px);
}

.modal.hidden { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 40, 0.24);
}
.modal-panel {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  width: min(900px, 96vw);
  height: min(82vh, 820px);
  border-radius: 20px;
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body {
  overflow: auto;
  padding: 8px;
}
.weekly-day {
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.65);
}

@media (max-width: 768px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-row { grid-template-columns: 1fr 1fr; }
  .weather-actions { display: block; }
}
