:root {
  color-scheme: light;
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #0b0b0f;
  --muted: #6b6f7a;
  --accent: #007aff;
  --accent-dark: #0056c7;
  --danger: #ff3b30;
  --line: rgba(60, 60, 67, 0.2);
  --shadow: 0 20px 40px rgba(12, 14, 24, 0.12);
  --radius: 18px;
  --font: "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Helvetica", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: radial-gradient(circle at top, #ffffff 0%, #f2f2f7 45%, #e6e8f0 100%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 430px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

.app-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 6px 18px;
}

.title {
  font-size: 28px;
  font-weight: 700;
}

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

.app-main {
  display: grid;
  gap: 18px;
}

.screen {
  display: none;
  flex-direction: column;
  gap: 18px;
  animation: fadeIn 0.4s ease;
}

.screen-active {
  display: flex;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-weight: 600;
  font-size: 16px;
}

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

.card-value {
  font-size: 16px;
  font-weight: 600;
}

.hero {
  text-align: center;
  align-items: center;
  gap: 10px;
  padding: 22px;
}

.hero-title {
  font-size: 18px;
  font-weight: 600;
}

.hero-sub {
  font-size: 13px;
  color: var(--muted);
}

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #eef0f6;
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
  width: 100%;
}

.segment-btn {
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.segment-btn.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 6px 16px rgba(16, 18, 28, 0.08);
}

.primary {
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border-radius: 14px;
  padding: 12px 18px;
  width: 100%;
  transition: transform 0.2s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary:active {
  transform: scale(0.98);
  background: var(--accent-dark);
}

.ghost {
  background: rgba(0, 122, 255, 0.12);
  border: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  border-radius: 14px;
  padding: 10px 14px;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.switch {
  position: relative;
  width: 52px;
  height: 30px;
  cursor: pointer;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .track {
  position: absolute;
  inset: 0;
  background: #d1d1d6;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.switch .thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.switch input:checked ~ .track {
  background: #34c759;
}

.switch input:checked ~ .thumb {
  transform: translateX(22px);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field select,
.ticker-add input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 16px;
  font-family: var(--font);
  color: var(--text);
}

.strategy-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.3;
}

.field input:disabled {
  opacity: 0.5;
}

.ticker-add {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 10px;
  align-items: center;
}

.circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  font-weight: 600;
}

.ticker-table {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.day.active {
  background: rgba(0, 122, 255, 0.12);
  color: var(--accent);
  border-color: rgba(0, 122, 255, 0.3);
}

.ticker-row {
  display: grid;
  grid-template-columns: 36px 1.2fr 0.8fr 0.6fr 32px;
  gap: 6px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.ticker-row.dimmed {
  opacity: 0.45;
}

.ticker-row.favorite {
  background: rgba(0, 122, 255, 0.08);
  border-radius: 12px;
  padding: 10px 6px;
}

.ticker-row.flash {
  animation: flashRow 0.6s ease;
}

.ticker-title {
  cursor: pointer;
}

.favorite-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  color: #f5c542;
  font-size: 14px;
}
.ticker-row:last-child {
  border-bottom: none;
}

.ticker-title {
  font-size: 14px;
  font-weight: 600;
}

.ticker-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #edf0f7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  overflow: hidden;
}

.ticker-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.remove {
  border: none;
  background: #ffe6e5;
  color: var(--danger);
  font-weight: 700;
  border-radius: 10px;
  padding: 6px 0;
}

.log {
  min-height: 280px;
  max-height: 420px;
  overflow: auto;
  background: #0b0b0f;
  color: #c7cad1;
  padding: 12px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.4;
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 10px 12px 24px;
}

.tab {
  background: transparent;
  border: none;
  font-family: var(--font);
  font-size: 12px;
  color: var(--muted);
  padding: 8px 4px;
}

.tab.active {
  color: var(--accent);
  font-weight: 600;
}

.pin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 14, 19, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.pin-overlay[hidden] {
  display: none;
}

.pin-card {
  background: #fff;
  border-radius: 22px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.pin-inputs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.pin-inputs input {
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
  font-size: 18px;
  padding: 8px 0;
  width: 100%;
  min-width: 0;
  height: 44px;
  -webkit-text-security: disc;
  -webkit-appearance: none;
  appearance: none;
}

.pin-inputs input[type="password"] {
  -webkit-text-security: disc;
}

.pin-error {
  font-size: 12px;
  color: var(--danger);
  min-height: 16px;
}

.pin-meta {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
  display: none;
}

.primary.loading .btn-label {
  opacity: 0.7;
}

.primary.loading .btn-spinner {
  display: inline-block;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: rgba(12, 12, 14, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 30;
}

.empty {
  min-height: 220px;
  align-items: center;
  justify-content: center;
  text-align: center;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes flashRow {
  0% {
    background: rgba(255, 204, 0, 0.28);
  }
  100% {
    background: transparent;
  }
}

@media (max-width: 390px) {
  .app {
    padding: 12px 12px 92px;
  }
  .ticker-row {
    grid-template-columns: 30px 1fr 0.8fr 0.6fr 28px;
  }
}
