:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --text: #1e2230;
  --muted: #6b7280;
  --primary: #4f8cff;
  --primary-dark: #3b73e0;
  --danger: #ef4444;
  --border: #e5e7eb;
  --card-soft: #fafbfd;
  --tag-bg: #f1f5ff;
  --warn-bg: #fff4e6;
  --danger-bg: #fee;
  --primary-soft: #eaf0ff;
  --shadow: 0 4px 18px rgba(30, 34, 48, 0.06);
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #0f1420;
  --surface: #1a2033;
  --text: #e6e9f0;
  --muted: #8a93a5;
  --primary: #6ba0ff;
  --primary-dark: #5a8ddf;
  --danger: #f87171;
  --border: #2a3144;
  --card-soft: #151b2c;
  --tag-bg: #1e2842;
  --warn-bg: #3b2e1a;
  --danger-bg: #3a1e1e;
  --primary-soft: #1e2842;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420;
    --surface: #1a2033;
    --text: #e6e9f0;
    --muted: #8a93a5;
    --primary: #6ba0ff;
    --primary-dark: #5a8ddf;
    --danger: #f87171;
    --border: #2a3144;
    --card-soft: #151b2c;
    --tag-bg: #1e2842;
    --warn-bg: #3b2e1a;
    --danger-bg: #3a1e1e;
    --primary-soft: #1e2842;
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

.app-header {
  padding: 20px 20px 4px;
  max-width: 720px;
  margin: 0 auto;
}

.header-card {
  background: linear-gradient(135deg,
    rgba(79, 140, 255, 0.10) 0%,
    rgba(167, 139, 250, 0.10) 50%,
    rgba(255, 175, 122, 0.08) 100%);
  border: 1px solid rgba(79, 140, 255, 0.15);
  border-radius: 20px;
  padding: 22px 22px 24px;
  position: relative;
  overflow: hidden;
}

.header-card::before {
  content: "";
  position: absolute;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.35) 0%, transparent 70%);
  top: -70px;
  right: -50px;
  pointer-events: none;
  border-radius: 50%;
}

.header-card::after {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(255, 175, 122, 0.30) 0%, transparent 70%);
  bottom: -50px;
  right: 30%;
  pointer-events: none;
  border-radius: 50%;
}

[data-theme="dark"] .header-card {
  background: linear-gradient(135deg,
    rgba(107, 160, 255, 0.12) 0%,
    rgba(167, 139, 250, 0.12) 50%,
    rgba(255, 175, 122, 0.08) 100%);
  border-color: rgba(107, 160, 255, 0.20);
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.header-text {
  display: flex;
  flex-direction: column;
}

.header-greeting {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.app-header h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--primary) 0%, #a78bfa 60%, #f59e8a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  line-height: 1.1;
}

.header-date {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--text);
  opacity: 0.75;
  font-weight: 500;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  transform: rotate(45deg);
  background: rgba(255, 255, 255, 0.7);
}

[data-theme="dark"] .icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}
[data-theme="dark"] .icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* settings dialog */
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-of-type {
  border-bottom: none;
}

.settings-title {
  font-size: 15px;
  font-weight: 500;
}

.settings-sub {
  margin-top: 2px;
}

.btn-ghost.danger {
  color: var(--danger);
  border-color: var(--danger);
  border-style: solid;
}

/* toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  transition: 0.2s;
  border-radius: 24px;
}

.slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--surface);
  transition: 0.2s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: var(--primary);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  animation: cardIn 0.4s ease-out both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.10s; }
.card:nth-child(4) { animation-delay: 0.15s; }

.card h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
  text-transform: none;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-head h2 {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

/* weather */
.weather-card {
  position: relative;
  overflow: hidden;
  color: var(--text);
  transition: background 0.5s ease;
}

.weather-card[data-mood="sunny"] {
  background: linear-gradient(135deg, #ffd875 0%, #ff9d5c 100%);
  color: #2a1c0f;
}
.weather-card[data-mood="cloudy"] {
  background: linear-gradient(135deg, #c7d4e5 0%, #97aecb 100%);
  color: #1e2230;
}
.weather-card[data-mood="rain"] {
  background: linear-gradient(135deg, #6b8cae 0%, #4a6c8f 100%);
  color: #f5f7fa;
}
.weather-card[data-mood="snow"] {
  background: linear-gradient(135deg, #e8eef5 0%, #b8c5d6 100%);
  color: #1e2230;
}
.weather-card[data-mood="fog"] {
  background: linear-gradient(135deg, #b6bdc4 0%, #8a909a 100%);
  color: #1e2230;
}
.weather-card[data-mood="storm"] {
  background: linear-gradient(135deg, #4a5270 0%, #2d324a 100%);
  color: #f5f7fa;
}

[data-theme="dark"] .weather-card[data-mood="sunny"] {
  background: linear-gradient(135deg, #8b6914 0%, #7a4a28 100%);
  color: #fff4d6;
}
[data-theme="dark"] .weather-card[data-mood="cloudy"] {
  background: linear-gradient(135deg, #2a3447 0%, #1a2138 100%);
  color: #e6e9f0;
}
[data-theme="dark"] .weather-card[data-mood="rain"] {
  background: linear-gradient(135deg, #253448 0%, #162033 100%);
  color: #dde4ee;
}
[data-theme="dark"] .weather-card[data-mood="snow"] {
  background: linear-gradient(135deg, #3a4354 0%, #272e3e 100%);
  color: #e6e9f0;
}
[data-theme="dark"] .weather-card[data-mood="fog"] {
  background: linear-gradient(135deg, #2f3440 0%, #1f2430 100%);
  color: #d8dce4;
}
[data-theme="dark"] .weather-card[data-mood="storm"] {
  background: linear-gradient(135deg, #1d2138 0%, #0f1224 100%);
  color: #dde4ee;
}

.weather-card h2 {
  color: inherit;
  opacity: 0.7;
}

.weather-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.weather-hero {
  display: flex;
  align-items: center;
  gap: 16px;
}

.weather-icon {
  font-size: 64px;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
  flex-shrink: 0;
}

.weather-core {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.weather-temp {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: inherit;
}

.weather-temp .deg {
  font-weight: 400;
  opacity: 0.7;
}

.weather-desc {
  font-size: 18px;
  font-weight: 500;
  color: inherit;
  opacity: 0.9;
}

.weather-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.weather-pill {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  font-weight: 500;
  white-space: nowrap;
}

[data-theme="dark"] .weather-pill,
.weather-card[data-mood="storm"] .weather-pill,
.weather-card[data-mood="rain"] .weather-pill {
  background: rgba(255, 255, 255, 0.15);
}

.weather-footer {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#weather-location {
  margin: 0;
  color: inherit;
  opacity: 0.75;
  font-weight: 500;
}
#weather-location::before {
  content: "📍 ";
}

.weather-card .btn-ghost {
  background: rgba(255, 255, 255, 0.25);
  border-color: transparent;
  color: inherit;
}
.weather-card .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.4);
  color: inherit;
}

.small-btn {
  padding: 5px 10px;
  font-size: 12px;
}

.loc-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 40vh;
  overflow-y: auto;
}

.loc-result {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}

.loc-result:hover {
  border-color: var(--primary);
  background: var(--tag-bg);
}

.loc-result .loc-name {
  font-weight: 600;
}

.loc-result .loc-region {
  font-size: 12px;
  color: var(--muted);
  margin-left: 6px;
}

/* outfit */
.outfit-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.outfit-list li {
  padding: 12px 16px;
  background: var(--tag-bg);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  border-left: 3px solid var(--primary);
}

.outfit-list li.warn {
  background: var(--warn-bg);
  border-left-color: #f59e0b;
}

/* schedule list */
.schedule-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-hint {
  text-align: center;
  padding: 20px 0;
  margin: 0;
}

.empty-state {
  text-align: center;
  padding: 24px 12px;
}

.empty-icon {
  font-size: 42px;
  margin-bottom: 8px;
  opacity: 0.85;
}

.empty-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.schedule-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--card-soft);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.schedule-item:hover {
  border-color: var(--primary);
}

.schedule-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.schedule-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.schedule-meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.schedule-items {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.schedule-items li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.schedule-items li.done label {
  text-decoration: line-through;
  color: var(--muted);
}

.schedule-items input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.schedule-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.edit-btn,
.delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
}

.edit-btn {
  color: var(--primary);
}

.edit-btn:hover {
  background: var(--primary-soft);
}

.delete-btn {
  color: var(--danger);
}

.delete-btn:hover {
  background: var(--danger-bg);
}

/* buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 8px rgba(79, 140, 255, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(79, 140, 255, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* dialog */
.schedule-dialog {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(92vw, 480px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  background: var(--surface);
  color: var(--text);
}

.schedule-dialog[open] {
  animation: dialogIn 0.25s ease-out;
}

@keyframes dialogIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: none; }
}

.schedule-dialog::backdrop {
  background: rgba(15, 20, 32, 0.55);
  backdrop-filter: blur(4px);
  animation: backdropIn 0.2s ease-out;
}

@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#schedule-form {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#schedule-form h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

#schedule-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

#schedule-form input[type="text"],
#schedule-form input[type="time"],
#schedule-form input[type="date"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}

#schedule-form input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

.row {
  display: flex;
  gap: 10px;
}

.row label {
  flex: 1;
}

.items-fieldset,
.repeat-fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.items-fieldset legend,
.repeat-fieldset legend {
  font-size: 13px;
  color: var(--muted);
  padding: 0 6px;
}

#schedule-form select,
#schedule-form input[type="number"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}

.items-inputs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.item-row {
  display: flex;
  gap: 6px;
}

.item-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}

.item-row button {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
  padding: 0 6px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* upcoming preview card */
.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upcoming-day {
  padding: 12px 14px;
  background: var(--card-soft);
  border-radius: 12px;
  border: 1px solid var(--border);
  transition: border-color 0.15s ease;
}

.upcoming-day:hover {
  border-color: var(--primary);
}

.upcoming-label {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 6px;
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary-soft);
  border-radius: 6px;
}

.upcoming-items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upcoming-items li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  align-items: baseline;
}

.upcoming-item-title {
  font-weight: 500;
}

.upcoming-meta {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

/* footer actions */
.footer-actions {
  display: flex;
  justify-content: center;
  padding: 8px 0 0;
}

/* past-schedule dialog */
.past-dialog-inner {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.past-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.past-head h3 {
  margin: 0;
  font-size: 18px;
}

.past-date-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.past-date-label input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}

.past-list {
  max-height: 55vh;
  overflow-y: auto;
}

/* read-only look for past items */
.past-list .schedule-item {
  background: var(--card-soft);
}

.past-list .schedule-items input[type="checkbox"] {
  pointer-events: none;
  opacity: 0.7;
}

@media (max-width: 420px) {
  .row {
    flex-direction: column;
  }
  .weather-temp {
    font-size: 40px;
  }
  .app-header h1 {
    font-size: 24px;
  }
}
