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

:root {
  /* Telegram theme vars (with warm fallbacks) */
  --bg:       var(--tg-theme-bg-color,           #FAF9F6);
  --surface:  var(--tg-theme-secondary-bg-color, #FFFFFF);
  --text:     var(--tg-theme-text-color,          #1a1a1a);
  --hint:     var(--tg-theme-hint-color,          #999999);
  --link:     var(--tg-theme-link-color,          #2481cc);
  --accent:   var(--tg-theme-button-color,        #B56B4A);
  --btn-text: var(--tg-theme-button-text-color,   #ffffff);
  --sep:      var(--tg-theme-secondary-bg-color,  #EDE9E3);

  /* Warm palette */
  --warm-bg:      #FAF9F6;
  --warm-surface: #FFFFFF;
  --warm-border:  #EDE9E3;

  /* Typography */
  --font:       -apple-system, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  --font-brand: 'Nunito', -apple-system, system-ui, sans-serif;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 12px; --r-pill: 100px;
}

html, body { height: 100%; overflow: hidden; background: var(--bg); }

body {
  font-family: var(--font);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell ── */
#app { position: relative; height: 100vh; overflow: hidden; }

#list-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ── Header ── */
.header {
  padding: 18px 18px 14px;
  background: var(--bg);
  flex-shrink: 0;
  border-bottom: 1px solid var(--sep);
}
.header-brand { display: flex; flex-direction: column; gap: 1px; }
.header-eyebrow {
  font-family: var(--font-brand);
  font-size: 14px;
  font-weight: 400;
  color: var(--hint);
  letter-spacing: 0.1px;
}
.header-title {
  font-family: var(--font-brand);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--sep);
  flex-shrink: 0;
}
.tab {
  flex: 1;
  padding: 11px 4px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--hint);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ── Search ── */
.search-wrap {
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--sep);
  flex-shrink: 0;
}
.search-wrap.hidden { display: none; }

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--hint);
  pointer-events: none;
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  padding: 11px 16px 11px 40px;
  border: 1px solid var(--warm-border);
  border-radius: var(--r-lg);
  background: var(--warm-surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--hint); }

/* ── Content scroll ── */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

/* ── Empty / hint ── */
.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--hint);
  font-size: 13px;
  line-height: 1.7;
}

/* ── Accordion group ── */
.group { border-bottom: 1px solid var(--sep); }

.group-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  border-radius: var(--r-md);
  transition: background 0.18s;
}

/* Open group: tinted header — bg set inline via JS */
.group.open .group-header {
  margin: 4px 8px 0;
  padding: 11px 12px;
  width: calc(100% - 16px);
  border-radius: var(--r-md) var(--r-md) 0 0;
}

.group-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.group-name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.group-count {
  font-size: 13px;
  color: var(--hint);
  margin-right: 2px;
}
.group-arrow {
  color: var(--hint);
  display: flex;
  align-items: center;
}
.group-arrow svg {
  transition: transform 0.25s ease;
}
.group.open .group-arrow svg {
  transform: rotate(90deg);
}

.group-items {
  padding: 6px 8px 10px;
  /* bg set inline via JS */
  margin: 0 8px;
  border-radius: 0 0 var(--r-md) var(--r-md);
}

/* ── Animations ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Take item ── */
.take-item {
  border-left: 3px solid transparent;
  margin-bottom: 6px;
  padding: 11px 13px;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--warm-surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  animation: fadeInUp 0.2s ease both;
  transition: box-shadow 0.2s, transform 0.1s;
}
.take-item:last-child { margin-bottom: 0; }
.take-item:active {
  box-shadow: 0 0 0 rgba(0,0,0,0);
  transform: scale(0.985);
}

/* flat list (Search) */
.flat-list { padding: 10px 16px; }
.flat-list .take-item {
  border-radius: var(--r-md);
  border-left: none;
  margin-bottom: 8px;
}

.take-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 4px;
}
.take-preview {
  font-size: 13px;
  color: var(--hint);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}
.take-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.take-date { font-size: 12px; color: var(--hint); }

.value-indicator { display: flex; align-items: center; gap: 4px; }
.value-dot { width: 6px; height: 6px; border-radius: 50%; background: #5A8A6C; flex-shrink: 0; }
.value-high  { font-size: 11px; color: #5A8A6C; }
.value-medium{ font-size: 11px; color: var(--hint); }

/* ── Detail screen ── */
.detail-screen {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.detail-screen.open { transform: translateX(0); }

.detail-topbar {
  position: relative;
  z-index: 2;
  padding: 10px 16px;
  border-bottom: 1px solid var(--sep);
  background: var(--bg);
  flex-shrink: 0;
}
.back-btn {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 17px;
  color: var(--link);
  cursor: pointer;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
}
.back-btn:active { opacity: 0.6; }

.detail-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* Colored gradient banner at top of detail — bg set inline via JS */
.detail-banner {
  height: 110px;
  position: absolute;
  top: 0; left: 0; right: 0;
  pointer-events: none;
}

.detail-inner {
  position: relative;
  z-index: 1;
  padding: 24px 18px calc(48px + env(safe-area-inset-bottom, 0px));
}

/* ── Detail content ── */
.cat-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  margin-bottom: 14px;
}
.detail-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.3px;
  margin-bottom: 16px;
  color: var(--text);
}
.detail-summary {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 20px;
}
.detail-summary p + p { margin-top: 14px; }

.action-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--hint);
  margin-bottom: 8px;
}
.action-box {
  padding: 14px 16px;
  border-radius: var(--r-lg);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
  margin-bottom: 20px;
}
.action-icon { margin-right: 6px; opacity: 0.8; }

.detail-divider { height: 1px; background: var(--sep); margin: 4px 0 16px; }

.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--hint);
}

.tools-row {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 16px;
  line-height: 1.5;
}
.tools-label { font-weight: 500; }

.chat-btn {
  display: block;
  text-align: center;
  padding: 13px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--btn-text);
  font-family: var(--font);
  font-weight: 500;
  font-size: 15px;
  text-decoration: none;
  margin-top: 16px;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.chat-btn:active { opacity: 0.8; }

.detail-date { font-size: 13px; color: var(--hint); margin-top: 14px; }
