/* ===== iOS Design System ===== */
:root {
  --topbar-color: #f8cbd0;
  --btn-color: var(--topbar-color);
  --btn-hover: #f4a1c1;
  --btn-active: #e588a8;

  --ios-blue:       #007AFF;
  --ios-bg:         #F2F2F7;
  --ios-card:       #FFFFFF;
  --ios-separator:  rgba(60,60,67,0.12);
  --ios-label:      #000000;
  --ios-label2:     rgba(60,60,67,0.6);
  --ios-label3:     rgba(60,60,67,0.3);
  --ios-fill:       rgba(120,120,128,0.20);
  --ios-fill2:      rgba(120,120,128,0.16);
  --ios-radius-sm:  10px;
  --ios-radius:     13px;
  --ios-radius-lg:  20px;
  --ios-radius-xl:  28px;
  --ios-shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --ios-shadow:     0 4px 20px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
  --ios-shadow-lg:  0 8px 40px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
}

/* ===== Reset ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  background: url('https://iili.io/KYiqrVj.webp') center/cover no-repeat fixed;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Sakura ===== */
.sakura {
  position: absolute;
  width: 12px; height: 12px;
  background: radial-gradient(circle, rgba(255,183,213,0.9) 0%, rgba(255,209,232,0.6) 50%, transparent 70%);
  border-radius: 50% 0 50% 0;
  opacity: 0.6;
  z-index: 1;
  pointer-events: none;
}
.sakura:nth-child(1){ left:8%;  top:0; }
.sakura:nth-child(2){ left:28%; top:0; }
.sakura:nth-child(3){ left:50%; top:0; }
.sakura:nth-child(4){ left:72%; top:0; }
.sakura:nth-child(5){ left:90%; top:0; }

/* ===== Top Section ===== */
.top-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 20px 12px;
  z-index: 2;
  color: #fff;
  text-align: center;
  position: relative;
  flex-shrink: 0;
}

.time {
  font-size: 3.6rem;
  font-weight: 200;
  letter-spacing: -2px;
  text-shadow: 0 2px 16px rgba(0,0,0,0.18);
  line-height: 1;
}

.date {
  margin-top: 6px;
  font-size: 0.95rem;
  font-weight: 400;
  opacity: 0.9;
  letter-spacing: 0.2px;
}

.weather-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 6px;
  gap: 2px;
  opacity: 0.88;
  font-size: 0.85rem;
}

/* ===== App Icon ===== */
.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.icon-wrapper {
  width: 76px;
  height: 76px;
  border-radius: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18), 0 1px 3px rgba(0,0,0,0.10);
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1);
  background: linear-gradient(135deg,#ff9a9e 0%,#fad0c4 100%);
  will-change: transform;
}

.icon-wrapper:active {
  transform: scale(0.90);
  transition: transform 0.08s ease;
}

.main-icon { font-size: 2.2rem; line-height: 1; }

.app-name {
  color: #fff;
  font-size: 0.78rem;
  font-weight: 400;
  text-shadow: 0 1px 6px rgba(0,0,0,0.35);
  text-align: center;
  max-width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.1px;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px 28px;
  width: 100%;
  max-width: 340px;
  justify-items: center;
}

/* ===== Bottom Section ===== */
.bottom-section {
  margin-top: auto;
  padding: 16px 20px 50px;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

/* ===== Modal ===== */
.app-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
}
.app-modal.active { display: flex; }
.app-modal .backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.40);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.panel {
  position: relative;
  width: 100%;
  max-width: 680px;
  background: var(--ios-card);
  border-radius: var(--ios-radius-xl) var(--ios-radius-xl) 0 0;
  overflow: hidden;
  box-shadow: var(--ios-shadow-lg);
  z-index: 9999;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  margin: 0;
}

.app-topbar {
  padding: 16px 20px;
  font-weight: 600;
  font-size: 17px;
  color: #fff;
  text-align: center;
  background-color: var(--topbar-color);
  position: relative;
  flex-shrink: 0;
}

.app-close {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.22);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.app-body {
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

/* ===== Buttons ===== */
.button-group { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

.btn,
button:not(.ios-back-btn):not(.chatroom-back-btn):not(.topbar-btn):not(.nav-btn) {
  padding: 11px 22px;
  border-radius: var(--ios-radius-lg);
  border: none;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  font-family: inherit;
  background: var(--btn-color) !important;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  transition: transform 0.12s ease, opacity 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.1px;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.96); opacity: 0.80; }

/* ===== iOS Nav Buttons (不受全局 button 影响) ===== */
.ios-back-btn,
.ios-nav-right button,
.nav-btn {
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 8px !important;
  transform: none !important;
  font-weight: 400 !important;
  font-size: 17px !important;
  color: #fff !important;
  border: none !important;
  height: 44px !important;
  cursor: pointer !important;
}
.ios-back-btn:active,
.ios-nav-right button:active {
  opacity: 0.55 !important;
  transform: none !important;
}

/* ===== Theme list ===== */
.theme-list { display: flex; flex-direction: column; gap: 8px; }
.theme-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--ios-radius);
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--ios-separator);
  font-weight: 500;
  font-size: 15px;
  color: var(--ios-label);
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.theme-item:hover { background: rgba(255,255,255,1); transform: translateY(-1px); }
.theme-item:active { transform: scale(0.98); }

/* ===== Status ===== */
.status { margin-top: 10px; color: var(--ios-label2); font-size: 13px; }

/* ===== API Form ===== */
.api-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.api-form label, .api-form input { flex: 1 1 200px; }
.api-form button { flex: 0 1 auto; }
@media (max-width: 500px) {
  .api-form { flex-direction: column; align-items: stretch; }
  .api-form label, .api-form input, .api-form button { width: 100%; }
}

/* ===== Weather Canvas ===== */
#weather-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: -1;
}

.top-section, .bottom-section, .desktop-container { position: relative; z-index: 2; }

/* ===== Responsive ===== */
@media (min-width: 769px) {
  .app-grid { max-width: 400px; gap: 24px 38px; }
  .icon-wrapper { width: 82px; height: 82px; border-radius: 19px; }
  .main-icon { font-size: 2.4rem; }
  .app-name { font-size: 0.82rem; max-width: 82px; }
  .time { font-size: 5rem; }
}
@media (min-width: 481px) and (max-width: 768px) {
  .app-grid { max-width: 360px; gap: 20px 32px; }
  .icon-wrapper { width: 78px; height: 78px; }
}
@media (max-width: 375px) {
  .top-section { padding: 44px 16px 12px; }
  .time { font-size: 3.8rem; }
  .app-grid { max-width: 290px; gap: 16px 20px; }
  .icon-wrapper { width: 64px; height: 64px; border-radius: 15px; }
  .main-icon { font-size: 1.9rem; }
  .app-name { font-size: 0.72rem; max-width: 64px; }
}
@media (max-width: 320px) {
  .app-grid { max-width: 250px; gap: 12px 14px; }
  .icon-wrapper { width: 56px; height: 56px; border-radius: 13px; }
  .main-icon { font-size: 1.7rem; }
  .app-name { font-size: 0.68rem; max-width: 56px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .top-section { padding: 10px 20px 8px; }
  .time { font-size: 2.6rem; }
  .bottom-section { padding: 8px 20px 20px; }
  .app-grid { max-width: 400px; gap: 10px 28px; }
  .icon-wrapper { width: 52px; height: 52px; }
  .main-icon { font-size: 1.5rem; }
  .app-name { font-size: 0.7rem; }
}

/* ===== iOS Status Bar ===== */
.ios-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px 0;
  height: 28px;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.status-time {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.25);
  letter-spacing: 0.2px;
  min-width: 36px;
}

.status-notch {
  width: 120px;
  height: 20px;
  background: rgba(0,0,0,0.75);
  border-radius: 0 0 18px 18px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.status-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-svg {
  width: 17px;
  height: 12px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
  flex-shrink: 0;
}

.battery-svg {
  width: 25px;
  height: 12px;
}

/* ===== iOS Navigation Bar (通用) ===== */
.ios-nav-bar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 8px 0 4px;
  background: var(--topbar-color, #f8cbd0);
  box-shadow: 0 0.5px 0 rgba(0,0,0,0.15);
  z-index: 100;
  -webkit-font-smoothing: antialiased;
  flex-shrink: 0;
}

.ios-back-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  background: transparent !important;
  border: none;
  color: #fff;
  font-size: 17px;
  font-weight: 400;
  padding: 0 8px;
  height: 44px;
  cursor: pointer;
  box-shadow: none !important;
  border-radius: 0 !important;
  min-width: 64px;
  -webkit-tap-highlight-color: transparent;
  transform: none !important;
}
.ios-back-btn svg {
  width: 11px; height: 18px;
  flex-shrink: 0;
  stroke: #fff;
  fill: none;
}
.ios-back-btn:active { opacity: 0.55; transform: none !important; }

.ios-nav-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.1px;
  white-space: nowrap;
  pointer-events: none;
}

.ios-nav-right {
  min-width: 64px;
  display: flex;
  justify-content: flex-end;
  padding-right: 8px;
  gap: 4px;
}

.ios-nav-right button {
  background: transparent !important;
  border: none;
  color: #fff;
  font-size: 17px;
  height: 44px;
  padding: 0 8px;
  cursor: pointer;
  box-shadow: none !important;
  border-radius: 0 !important;
}
.ios-nav-right button:active { opacity: 0.55; }
