/* ── Shell ──────────────────────────────────────── */

.lk-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

/* ── Portrait-mode prompt ───────────────────────── */

.lk-rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
@media (orientation: portrait) and (max-width: 640px) {
  .lk-rotate-overlay { display: flex; }
}
.lk-rotate-title { font-size: var(--fs-18); font-weight: 600; font-family: var(--font-sans); color: var(--ink); }
.lk-rotate-sub   { font-size: var(--fs-12); font-family: var(--font-sans); color: var(--ink-mid); text-align: center; max-width: 240px; }

/* ── Top bar — matches ActiveKnitting ───────────── */

.lk-topbar {
  height: 44px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.lk-tb-back {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-mid);
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  cursor: pointer;
  flex-shrink: 0;
}
.lk-tb-back:hover { border-color: var(--accent); color: var(--accent); }

.lk-tb-pattern {
  font-size: var(--fs-10);
  font-weight: 400;
  color: var(--ink-mid);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lk-mode-pill {
  font-family: var(--font-sans);
  font-size: var(--fs-9);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-md);
  padding: 2px 7px;
  flex-shrink: 0;
}
.lk-mode-pill-round {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.lk-mode-pill-flat {
  background: color-mix(in srgb, #8b5cf6 15%, transparent);
  color: #8b5cf6;
  border: 1px solid color-mix(in srgb, #8b5cf6 40%, transparent);
}

.lk-tb-chip {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  height: 30px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 6px;
}
.lk-tb-chip-label {
  font-size: var(--fs-9);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-light);
}
.lk-tb-chip-num {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--fs-15);
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}
.lk-tb-chip-sep {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--fs-12);
  color: var(--ink-mid);
}
.lk-tb-chip-sub {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--fs-12);
  color: var(--ink-mid);
}

/* ── Split minus button ─────────────────────────── */

.lk-split-wrap { position: relative; display: flex; flex-shrink: 0; }

.lk-split-main {
  height: 24px;
  border: none;
  border-right: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  font-weight: 600;
  cursor: pointer;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.lk-split-main:hover { opacity: 0.88; }
.lk-split-main:disabled { opacity: 0.35; cursor: default; pointer-events: none; }

.lk-split-arrow {
  height: 24px;
  width: 20px;
  border: 1px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--accent-lt);
  color: var(--accent);
  font-size: var(--fs-10);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lk-split-arrow:hover { opacity: 0.8; }

.lk-back-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  min-width: 180px;
  z-index: 200;
}

.lk-back-menu-item {
  width: 100%;
  height: 38px;
  padding: 0 14px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.lk-back-menu-item:last-child { border-bottom: none; }
.lk-back-menu-item:hover { background: var(--surface2); }
.lk-back-menu-danger { color: var(--danger); }
.lk-back-menu-danger:hover { background: var(--danger-lt); }

/* ── Next/plus button ───────────────────────────── */

.lk-next-btn {
  height: 24px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  font-weight: 600;
  cursor: pointer;
  padding: 0 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.lk-next-btn:hover { opacity: 0.88; }

/* ── Timer chip ─────────────────────────────────── */

.lk-tb-timer-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--ink-light);
}
.lk-tb-timer-chip:hover { border-color: var(--accent); }
.lk-tb-timer-running { width: auto; padding: 0 8px; background: var(--accent-lt); border-color: var(--accent); color: var(--accent); }
.lk-tb-timer-display {
  font-family: var(--font-mono);
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}

/* ── Icon buttons ───────────────────────────────── */

.lk-tb-icon {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-mid);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lk-tb-icon:hover { background: var(--accent-lt); color: var(--accent); border-color: var(--accent); }
.lk-tb-icon-active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ── Stitch key panel ───────────────────────────── */

.lk-panel {
  position: absolute;
  top: 44px;
  right: 0;
  width: 280px;
  max-height: calc(100dvh - 44px - 48px);
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 50;
}
.lk-panel-open { transform: translateX(0); }

.lk-panel-title {
  font-family: var(--font-sans);
  font-size: var(--fs-10);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-mid);
}

.lk-key-image { width: 100%; border-radius: var(--radius-md); display: block; }

.lk-key-empty {
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  color: var(--ink-light);
  font-style: italic;
}

/* ── Swipeable pages ────────────────────────────── */

.lk-pages-wrap {
  flex: 1;
  display: flex;
  overflow-x: scroll;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  min-height: 0;
}
.lk-pages-wrap::-webkit-scrollbar { display: none; }

.lk-page {
  flex-shrink: 0;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  overflow: hidden;
}

.lk-page-inner {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 12px;
  background: #F0F2F4;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.lk-chart-img-wrap {
  display: block;
  position: relative;
  line-height: 0;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.lk-chart-img {
  display: block;
  width: 100%;
  height: auto;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.lk-row-highlight {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(99, 102, 241, 0.15);
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  pointer-events: none;
}

.lk-chart-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
}

.lk-placeholder-text {
  font-size: var(--fs-12);
  color: var(--ink-light);
  font-style: italic;
}

/* ── Chart tab strip ────────────────────────────── */

.lk-dots-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: 38px;
}

.lk-dot {
  font-family: var(--font-sans);
  font-size: var(--fs-10);
  color: var(--ink-mid);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 3px 12px;
  cursor: pointer;
}
.lk-dot:hover { border-color: var(--accent); color: var(--accent); }
.lk-dot-active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
