/* AIKI WebApp base styles — Claude-style dark theme */

html,
body {
  height: var(--app-height, 100dvh);
  font-family: 'Inter', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: var(--app-height, 100dvh);
}

::selection {
  background: rgba(167, 139, 250, 0.3);
  color: #FAF9F6;
}

button,
input,
textarea,
label {
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid #A78BFA;
  outline-offset: 2px;
}

/* Subtle scrollbar for overflow areas */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

/* Ensure consistent safe-area handling on modern devices */
body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app-screen {
  min-height: 0;
}

.sticky-action {
  flex: 0 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(15, 17, 21, 0), #0F1115 22%);
}

.ai-loader {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 32px;
}

.ai-loader span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #A78BFA;
  animation: aiki-pulse 900ms ease-in-out infinite;
}

.ai-loader span:nth-child(2) {
  animation-delay: 120ms;
}

.ai-loader span:nth-child(3) {
  animation-delay: 240ms;
}

.ai-loader-small span {
  width: 4px;
  height: 4px;
}

.home-action {
  display: flex;
  min-height: 74px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: #181A20;
  color: #FAF9F6;
  text-align: center;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.home-action:active {
  transform: scale(0.98);
}

.home-action-primary {
  border-color: rgba(167, 139, 250, 0.58);
  background: #A78BFA;
  color: white;
  box-shadow: 0 14px 34px rgba(167, 139, 250, 0.24);
}

.home-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: end;
  gap: 8px;
  min-height: 144px;
}

.home-chart-day {
  display: grid;
  grid-template-rows: 18px 96px 18px;
  gap: 6px;
  min-width: 0;
  text-align: center;
}

.home-chart-value {
  color: #9CA3AF;
  font-size: 11px;
  line-height: 18px;
}

.home-chart-track {
  position: relative;
  display: flex;
  align-items: end;
  min-height: 96px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.home-chart-bar {
  width: 100%;
  min-height: 8px;
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, #A78BFA, #6366F1);
  animation: chart-rise 520ms ease-out both;
  transform-origin: bottom;
}

.home-chart-bar.is-empty {
  background: rgba(255, 255, 255, 0.16);
}

.home-chart-day span {
  color: #9CA3AF;
  font-size: 11px;
  line-height: 18px;
}

.ai-orbit {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 2px solid rgba(167, 139, 250, 0.2);
  border-top-color: #A78BFA;
  animation: aiki-spin 900ms linear infinite;
}

.tour-shell {
  height: 100%;
  background:
    radial-gradient(circle at 50% -8%, rgba(167, 139, 250, 0.18), transparent 34%),
    #0F1115;
  overflow: hidden;
}

.tour-stage {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: #0F1115;
}

.tour-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  background: linear-gradient(180deg, #0F1115 72%, rgba(15, 17, 21, 0));
}

.tour-eyebrow {
  color: #9CA3AF;
  font-size: 12px;
  line-height: 1;
  margin-bottom: 6px;
}

.tour-title {
  color: #FAF9F6;
  font-size: 24px;
  font-weight: 650;
  line-height: 1.1;
}

.tour-skip {
  min-height: 44px;
  padding: 0 12px;
  color: #9CA3AF;
  font-size: 14px;
}

.tour-progress {
  position: absolute;
  top: 76px;
  left: 18px;
  right: 18px;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.tour-progress span {
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.tour-progress span::after {
  content: "";
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: #A78BFA;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 240ms ease;
}

.tour-progress span.is-active::after {
  transform: scaleX(1);
}

.tour-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 112px 16px 28px;
  scroll-padding: 160px 0 260px;
}

.tour-demo-block {
  margin-bottom: 18px;
}

.tour-demo-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: #9CA3AF;
  font-size: 12px;
}

.tour-review-card,
.tour-notes-box,
.tour-stats-panel {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background: #181A20;
  padding: 18px;
}

.tour-review-card {
  margin-bottom: 12px;
}

.tour-icon-btn,
.tour-mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  color: #9CA3AF;
  background: rgba(255, 255, 255, 0.03);
}

.tour-input,
.tour-textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: #1F2128;
  color: #FAF9F6;
}

.tour-input {
  min-height: 52px;
  padding: 0 14px;
  font-size: 15px;
}

.tour-textarea {
  min-height: 112px;
  padding: 14px;
  resize: none;
  font-size: 15px;
  line-height: 1.45;
}

.tour-feedback {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-radius: 14px;
  background: rgba(52, 211, 153, 0.1);
  color: #34D399;
  padding: 12px;
  font-size: 14px;
}

.tour-feedback-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #34D399;
}

.tour-main-btn,
.tour-topic-btn,
.tour-file-btn,
.tour-ghost-btn {
  width: 100%;
  min-height: 56px;
  border-radius: 18px;
  font-weight: 650;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.tour-main-btn {
  background: #A78BFA;
  color: white;
}

.tour-topic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #181A20;
  color: #FAF9F6;
}

.tour-file-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #1F2128;
  color: #A78BFA;
  font-size: 14px;
}

.tour-ghost-btn {
  background: transparent;
  color: #9CA3AF;
  font-size: 14px;
  font-weight: 550;
}

.tour-generated-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.tour-generated-list div {
  display: flex;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
}

.tour-generated-list span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.18);
  color: #C4B5FD;
  font-size: 12px;
}

.tour-generated-list p {
  color: #FAF9F6;
  font-size: 13px;
  line-height: 1.35;
}

.tour-stats-panel {
  display: grid;
  gap: 18px;
}

.tour-stats-panel strong {
  display: block;
  margin-top: 4px;
  color: #FAF9F6;
  font-size: 42px;
  line-height: 1;
}

.tour-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 7px;
  height: 78px;
}

.tour-bars span {
  min-height: 8px;
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, #A78BFA, #6366F1);
}

.tour-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  background:
    radial-gradient(circle at var(--spot-x, 50%) var(--spot-y, 45%), transparent 0 72px, rgba(0, 0, 0, 0.54) 112px),
    rgba(0, 0, 0, 0.18);
}

.tour-target {
  position: relative;
  z-index: 25;
}

.tour-highlight {
  border-color: rgba(167, 139, 250, 0.72) !important;
  box-shadow:
    0 0 0 3px rgba(167, 139, 250, 0.62),
    0 0 34px rgba(167, 139, 250, 0.46),
    0 14px 38px rgba(0, 0, 0, 0.34);
  animation: tour-breathe 1800ms ease-in-out infinite;
}

.tour-card {
  position: absolute;
  left: 14px;
  right: 14px;
  z-index: 45;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0)),
    #181A20;
  padding: 18px;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.58);
  transition: top 220ms ease;
}

.tour-card-arrow {
  position: absolute;
  left: var(--arrow-left);
  width: 2px;
  height: 34px;
  background: linear-gradient(180deg, rgba(167, 139, 250, 0), #A78BFA);
}

.tour-card-arrow::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 12px;
  height: 12px;
  border-right: 2px solid #A78BFA;
  border-bottom: 2px solid #A78BFA;
}

.tour-card.is-above .tour-card-arrow {
  bottom: -34px;
  transform: translateX(-50%) rotate(180deg);
}

.tour-card.is-above .tour-card-arrow::after {
  bottom: -2px;
  transform: translateX(-50%) rotate(45deg);
}

.tour-card.is-below .tour-card-arrow {
  top: -34px;
  transform: translateX(-50%);
}

.tour-card.is-below .tour-card-arrow::after {
  bottom: -2px;
  transform: translateX(-50%) rotate(45deg);
}

.tour-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 28px;
  border-radius: 999px;
  background: #1F2128;
  color: #9CA3AF;
  font-size: 12px;
}

.tour-primary-btn,
.tour-secondary-btn {
  flex: 1;
  min-height: 46px;
  border-radius: 14px;
  font-weight: 650;
}

.tour-primary-btn {
  background: #A78BFA;
  color: white;
}

.tour-secondary-btn {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #1F2128;
  color: #FAF9F6;
}

.tour-secondary-btn:disabled {
  opacity: 0.42;
}

@keyframes aiki-pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

@keyframes aiki-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes chart-rise {
  from {
    opacity: 0.5;
    transform: scaleY(0.2);
  }
  to {
    opacity: 1;
    transform: scaleY(1);
  }
}

@keyframes tour-breathe {
  0%,
  100% {
    box-shadow:
      0 0 0 3px rgba(167, 139, 250, 0.56),
      0 0 28px rgba(167, 139, 250, 0.38),
      0 14px 38px rgba(0, 0, 0, 0.34);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(167, 139, 250, 0.74),
      0 0 42px rgba(167, 139, 250, 0.52),
      0 16px 46px rgba(0, 0, 0, 0.38);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-loader span,
  .ai-orbit,
  .tour-highlight {
    animation: none;
  }

  .tour-card,
  .tour-progress span::after,
  .home-action,
  .home-chart-bar,
  .tour-main-btn,
  .tour-topic-btn,
  .tour-file-btn,
  .tour-ghost-btn {
    transition: none;
  }
}
