/* Material You (Material 3) для мини-приложения «Крипто» */

:root {
  /* цветовые роли M3 (светлая тема) */
  --primary: #6750A4;
  --on-primary: #FFFFFF;
  --primary-container: #EADDFF;
  --on-primary-container: #21005D;
  --secondary-container: #E8DEF8;
  --on-secondary-container: #1D192B;
  --tertiary-container: #FFD8E4;
  --on-tertiary-container: #31111D;
  --error: #B3261E;
  --error-container: #F9DEDC;
  --on-error-container: #410E0B;
  --success: #146C2E;
  --surface: #FEF7FF;
  --surface-tint: #6750A4;
  --on-surface: #1D1B20;
  --surface-variant: #E7E0EC;
  --on-surface-variant: #49454F;
  --surface-container-lowest: #FFFFFF;
  --surface-container-low: #F7F2FA;
  --surface-container: #F3EDF7;
  --surface-container-high: #ECE6F0;
  --surface-container-highest: #E6E0E9;
  --outline: #79747E;
  --outline-variant: #CAC4D0;
  --inverse-surface: #322F35;
  --inverse-on-surface: #F5EFF7;
  --scrim: rgba(0, 0, 0, .34);

  /* тени M3 */
  --elev1: 0 1px 2px rgba(0,0,0,.12), 0 1px 3px 1px rgba(0,0,0,.08);
  --elev2: 0 1px 2px rgba(0,0,0,.14), 0 2px 6px 2px rgba(0,0,0,.10);
  --elev3: 0 4px 8px 3px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.16);

  /* форма M3 */
  --shape-xs: 8px;
  --shape-sm: 12px;
  --shape-md: 16px;
  --shape-lg: 20px;
  --shape-xl: 28px;
  --shape-full: 999px;

  /* движение M3 */
  --ease-standard: cubic-bezier(.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(.2, .8, .2, 1);
}

[data-theme="dark"] {
  --primary: #D0BCFF;
  --on-primary: #381E72;
  --primary-container: #4F378B;
  --on-primary-container: #EADDFF;
  --secondary-container: #4A4458;
  --on-secondary-container: #E8DEF8;
  --tertiary-container: #633B48;
  --on-tertiary-container: #FFD8E4;
  --error: #F2B8B5;
  --error-container: #8C1D18;
  --on-error-container: #F9DEDC;
  --success: #7BD88F;
  --surface: #141218;
  --surface-tint: #D0BCFF;
  --on-surface: #E6E0E9;
  --surface-variant: #49454F;
  --on-surface-variant: #CAC4D0;
  --surface-container-lowest: #0F0D13;
  --surface-container-low: #1D1B20;
  --surface-container: #211F26;
  --surface-container-high: #2B2930;
  --surface-container-highest: #36343B;
  --outline: #938F99;
  --outline-variant: #49454F;
  --inverse-surface: #E6E0E9;
  --inverse-on-surface: #322F35;
  --scrim: rgba(0, 0, 0, .55);
  --elev1: 0 1px 2px rgba(0,0,0,.5), 0 1px 3px 1px rgba(0,0,0,.3);
  --elev2: 0 1px 2px rgba(0,0,0,.5), 0 2px 6px 2px rgba(0,0,0,.3);
  --elev3: 0 4px 8px 3px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--surface);
  color: var(--on-surface);
  font-family: 'Roboto', -apple-system, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

#app { min-height: 100vh; padding-bottom: calc(104px + env(safe-area-inset-bottom)); }

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; }
input { font: inherit; }
svg { fill: currentColor; width: 24px; height: 24px; display: block; flex: none; }

/* --- типы M3 --- */
.t-display { font-size: 34px; line-height: 40px; font-weight: 500; letter-spacing: -1px; }
.t-headline { font-size: 26px; line-height: 32px; font-weight: 500; letter-spacing: -.4px; }
.t-title-lg { font-size: 21px; line-height: 28px; font-weight: 500; }
.t-title { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: .15px; }
.t-label { font-size: 13px; line-height: 18px; font-weight: 500; letter-spacing: .4px; }
.t-body { font-size: 14px; line-height: 20px; letter-spacing: .25px; }

/* --- верхняя панель --- */
.top-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 12px 12px 20px;
  background: var(--surface);
  transition: background .25s var(--ease-standard), box-shadow .25s var(--ease-standard);
}
.top-bar.is-scrolled {
  background: var(--surface-container);
  box-shadow: var(--elev1);
}
.top-bar h1 { font-size: 26px; line-height: 32px; font-weight: 500; letter-spacing: -.4px; }
.top-bar .sub { font-size: 12.5px; color: var(--on-surface-variant); margin-top: -2px; }
.top-bar .spacer { flex: 1; }

.icon-btn {
  width: 48px; height: 48px; flex: none;
  border-radius: var(--shape-full);
  display: grid; place-items: center;
  color: var(--on-surface-variant);
  position: relative; overflow: hidden;
  transition: background .18s var(--ease-standard);
}
.icon-btn:active { background: var(--surface-container-high); }
.icon-btn.spin svg { animation: spin .9s var(--ease-emphasized) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- виды --- */
main { padding: 0 16px; }
.view { display: none; }
.view.is-active { display: block; animation: fade .28s var(--ease-emphasized); }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.stack { display: flex; flex-direction: column; gap: 12px; }
.section-title { font-size: 16px; font-weight: 500; letter-spacing: .15px; margin: 6px 4px 14px; }

/* --- герой --- */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: var(--shape-xl);
  padding: 22px 24px 24px;
  margin-bottom: 18px;
}
.hero::after {
  content: '';
  position: absolute; right: -40px; top: -60px;
  width: 190px; height: 190px;
  border-radius: 50%;
  background: var(--tertiary-container);
  opacity: .55;
}
.hero > * { position: relative; z-index: 1; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero-label { font-size: 13px; font-weight: 500; letter-spacing: .4px; opacity: .85; }
.hero-badge {
  font-size: 12px; font-weight: 600; letter-spacing: .6px;
  padding: 5px 12px;
  border-radius: var(--shape-full);
  background: var(--on-primary-container);
  color: var(--primary-container);
}
.hero-value { font-size: 34px; line-height: 40px; font-weight: 500; letter-spacing: -1px; margin-top: 8px; }
.hero-sub { font-size: 14px; opacity: .85; margin-top: 4px; }

/* --- карточка --- */
.card {
  background: var(--surface-container);
  border-radius: var(--shape-xl);
  padding: 20px;
  margin-bottom: 14px;
}
.card-title { font-size: 16px; font-weight: 500; letter-spacing: .15px; }
.card-sub { font-size: 13px; color: var(--on-surface-variant); margin-top: 6px; }

/* --- монета в списке --- */
.coin-card {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  background: var(--surface-container);
  border-radius: var(--shape-xl);
  padding: 14px 18px 14px 14px;
  position: relative; overflow: hidden;
  transition: background .18s var(--ease-standard);
}
.coin-card:active { background: var(--surface-container-high); }

.coin-avatar {
  width: 46px; height: 46px; flex: none;
  border-radius: var(--shape-full);
  display: grid; place-items: center;
  font-weight: 600; font-size: 17px;
  background: hsl(var(--hue, 265) 48% 90%);
  color: hsl(var(--hue, 265) 55% 32%);
}
[data-theme="dark"] .coin-avatar {
  background: hsl(var(--hue, 265) 26% 28%);
  color: hsl(var(--hue, 265) 75% 88%);
}
.coin-avatar.lg { width: 60px; height: 60px; font-size: 24px; }
.coin-avatar.sm { width: 40px; height: 40px; font-size: 15px; }

.coin-main { flex: 1; min-width: 0; }
.coin-name, .coin-symbol, .coin-price, .coin-change,
.alert-title, .alert-sub { display: block; }
.coin-name { font-size: 16px; font-weight: 500; letter-spacing: .1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coin-symbol { font-size: 12.5px; color: var(--on-surface-variant); letter-spacing: .6px; margin-top: 1px; }

.coin-right { text-align: right; flex: none; }
.coin-price { font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
.coin-change { font-size: 12.5px; font-weight: 500; margin-top: 2px; }
.up { color: var(--success); }
.down { color: var(--error); }

/* --- кнопки --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 0 24px;
  border-radius: var(--shape-full);
  font-size: 14.5px; font-weight: 500; letter-spacing: .1px;
  position: relative; overflow: hidden;
  transition: filter .15s var(--ease-standard), box-shadow .2s var(--ease-standard);
}
.btn:active { filter: brightness(.94); }
.btn.filled { background: var(--primary); color: var(--on-primary); box-shadow: var(--elev1); }
.btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn.outlined { box-shadow: inset 0 0 0 1px var(--outline); color: var(--primary); }
.btn.text { color: var(--primary); padding: 0 16px; }
.btn.danger { background: var(--error-container); color: var(--on-error-container); }
.btn:disabled { opacity: .38; pointer-events: none; }
.btn.small { min-height: 38px; padding: 0 18px; font-size: 13.5px; }
.btn svg { width: 18px; height: 18px; }

.ripple {
  position: absolute; border-radius: 50%;
  background: currentColor; opacity: .16;
  transform: scale(0); animation: ripple .6s var(--ease-standard) forwards;
  pointer-events: none;
}
@keyframes ripple { to { transform: scale(2.8); opacity: 0; } }

/* --- чипы --- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: var(--shape-xs);
  box-shadow: inset 0 0 0 1px var(--outline-variant);
  color: var(--on-surface-variant);
  font-size: 13.5px; font-weight: 500;
  position: relative; overflow: hidden;
  transition: background .18s var(--ease-standard);
}
.chip:active { background: var(--surface-container-high); }

/* --- поиск --- */
.search-bar {
  display: flex; align-items: center; gap: 12px;
  height: 56px;
  background: var(--surface-container-high);
  border-radius: var(--shape-full);
  padding: 0 18px;
  margin-bottom: 16px;
  color: var(--on-surface-variant);
  box-shadow: var(--elev1);
}
.search-bar input {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  color: var(--on-surface);
  font-size: 16px;
}
.search-bar input::placeholder { color: var(--on-surface-variant); }

/* --- сегментированные кнопки --- */
.segmented {
  display: flex;
  border: 1px solid var(--outline);
  border-radius: var(--shape-full);
  overflow: hidden;
  margin-top: 14px;
}
.segmented button {
  flex: 1;
  min-height: 42px;
  font-size: 13.5px; font-weight: 500;
  color: var(--on-surface);
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .2s var(--ease-standard);
}
.segmented button + button { border-left: 1px solid var(--outline); }
.segmented button.is-active { background: var(--secondary-container); color: var(--on-secondary-container); }
.segmented button.is-active::before {
  content: '';
  width: 15px; height: 15px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/></svg>") center/contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/></svg>") center/contain no-repeat;
}

/* --- сигналы --- */
.alert-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface-container);
  border-radius: var(--shape-xl);
  padding: 14px 10px 14px 16px;
}
.alert-info { flex: 1; min-width: 0; }
.alert-title { font-size: 15px; font-weight: 500; }
.alert-sub { font-size: 12.5px; color: var(--on-surface-variant); margin-top: 2px; }

/* --- пустые состояния --- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px;
  padding: 40px 24px;
  background: var(--surface-container-low);
  border-radius: var(--shape-xl);
}
.empty-state .empty-icon {
  width: 64px; height: 64px;
  border-radius: var(--shape-full);
  display: grid; place-items: center;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  margin-bottom: 8px;
}
.empty-state .empty-icon svg { width: 30px; height: 30px; }
.empty-title { font-size: 16px; font-weight: 500; }
.empty-text { font-size: 13.5px; color: var(--on-surface-variant); max-width: 260px; }
.empty-state .chips { justify-content: center; margin-top: 16px; }

/* --- скелет загрузки --- */
.skeleton {
  height: 74px;
  border-radius: var(--shape-xl);
  background: linear-gradient(90deg,
    var(--surface-container) 25%,
    var(--surface-container-high) 50%,
    var(--surface-container) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.hint { margin-top: 16px; color: var(--on-surface-variant); font-size: 12.5px; line-height: 1.5; }

/* --- нижняя навигация --- */
.nav-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  display: flex; justify-content: space-around;
  padding: 12px 8px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface-container);
  border-radius: var(--shape-xl) var(--shape-xl) 0 0;
  box-shadow: var(--elev2);
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--on-surface-variant);
}
.nav-pill {
  width: 64px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--shape-full);
  transition: background .22s var(--ease-emphasized);
}
.nav-item.is-active { color: var(--on-surface); }
.nav-item.is-active .nav-pill { background: var(--secondary-container); color: var(--on-secondary-container); }
.nav-label { font-size: 12px; font-weight: 500; letter-spacing: .3px; }

/* --- расширенная FAB --- */
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(112px + env(safe-area-inset-bottom));
  z-index: 35;
  display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 20px;
  border-radius: var(--shape-md);
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-size: 15px; font-weight: 500; letter-spacing: .1px;
  box-shadow: var(--elev3);
  overflow: hidden;
  transition: transform .2s var(--ease-emphasized), box-shadow .2s var(--ease-standard);
}
.fab:active { transform: scale(.96); }

/* --- шторка --- */
.backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: var(--scrim);
  opacity: 0; pointer-events: none;
  transition: opacity .28s var(--ease-standard);
}
.backdrop.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface-container-low);
  border-radius: var(--shape-xl) var(--shape-xl) 0 0;
  padding: 8px 22px calc(28px + env(safe-area-inset-bottom));
  transform: translateY(102%);
  visibility: hidden;
  pointer-events: none;
  transition: transform .34s var(--ease-emphasized), visibility .34s;
  box-shadow: var(--elev3);
}
.sheet.is-open { transform: translateY(0); visibility: visible; pointer-events: auto; }
.sheet-handle {
  width: 32px; height: 4px; border-radius: var(--shape-full);
  background: var(--outline-variant);
  margin: 8px auto 18px;
}
.sheet-head { display: flex; align-items: center; gap: 16px; }
.sheet-head .icon-btn { margin-left: auto; }
.sheet-title { font-size: 22px; line-height: 28px; font-weight: 500; }
.sheet-sub { font-size: 13px; color: var(--on-surface-variant); letter-spacing: .6px; margin-top: 2px; }

.sheet-price { font-size: 36px; line-height: 42px; font-weight: 500; letter-spacing: -1px; margin: 22px 0 2px; }
.sheet-change { font-size: 14px; font-weight: 500; }

.chart-wrap { margin: 20px 0 4px; }
.chart-wrap svg { width: 100%; height: 118px; display: block; }
.chart-meta {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--on-surface-variant);
  margin-top: 6px; letter-spacing: .3px;
}
.chart-tabs { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.chart-tabs button {
  min-height: 36px; padding: 0 16px;
  border-radius: var(--shape-full);
  font-size: 13px; font-weight: 500;
  color: var(--on-surface-variant);
  position: relative; overflow: hidden;
  transition: background .2s var(--ease-standard);
}
.chart-tabs button.is-active { background: var(--secondary-container); color: var(--on-secondary-container); }

.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.sheet-actions .btn { flex: 1 1 auto; }

.field { display: block; margin-top: 18px; }
.field span { display: block; font-size: 12.5px; font-weight: 500; color: var(--on-surface-variant); margin-bottom: 8px; letter-spacing: .4px; }
.field input {
  width: 100%;
  background: var(--surface-container-high);
  border: none; outline: none;
  border-radius: var(--shape-sm);
  padding: 16px;
  font-size: 16px;
  color: var(--on-surface);
  transition: box-shadow .18s var(--ease-standard);
}
.field input:focus { box-shadow: inset 0 0 0 2px var(--primary); }

.alert-form { margin-top: 8px; }
.alert-form .btn { width: 100%; margin-top: 20px; }

.time-input {
  background: var(--surface-container-high);
  border: none; outline: none;
  border-radius: var(--shape-sm);
  padding: 14px 16px;
  font-size: 15px;
  color: var(--on-surface);
  color-scheme: light dark;
}
.digest-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }

/* --- снекбар --- */
.snackbar {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(104px + env(safe-area-inset-bottom));
  z-index: 60;
  background: var(--inverse-surface);
  color: var(--inverse-on-surface);
  border-radius: var(--shape-xs);
  padding: 16px 18px;
  font-size: 14px;
  box-shadow: var(--elev3);
  opacity: 0;
  visibility: hidden;
  pointer-events: none; /* подсказка никогда не перехватывает нажатия */
  transform: translateY(16px);
  transition: opacity .22s var(--ease-standard), transform .3s var(--ease-emphasized), visibility .3s;
}
.snackbar.is-open { opacity: 1; visibility: visible; transform: translateY(0); }
