/* ===== Kikite App — Design Tokens ===== */
:root {
  --kikite-gradient: linear-gradient(135deg, #6B7FE3 0%, #A855C8 50%, #F0449A 100%);
  --kikite-primary: #A855C8;
  --kikite-secondary: #6B7FE3;
  --kikite-accent: #F0449A;
  --bg: #F8F7FC;
  --surface: #FFFFFF;
  --text: #1A1A2E;
  --text-secondary: #5A5A78;
  --border: #E8E6F0;
  --danger: #E53E3E;
  --success: #38A169;
  --warning: #DD6B20;
  --shadow-sm: 0 1px 4px rgba(26,26,46,0.06);
  --shadow-md: 0 4px 16px rgba(26,26,46,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  --tab-height: 60px;
  --header-height: 52px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Noto Sans JP", system-ui, -apple-system, "Hiragino Kaku Gothic ProN", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
input, textarea, select { font: inherit; }
:focus-visible { outline: 2px solid var(--kikite-primary); outline-offset: 2px; border-radius: 4px; }
ul { list-style: none; padding: 0; margin: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===== App Shell ===== */
.app { position: relative; max-width: 430px; margin: 0 auto; min-height: 100dvh; }

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
}
.app-header-logo img { height: 28px; }
.app-header-title {
  font-size: 17px;
  font-weight: 700;
}
.app-header-back {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--kikite-primary);
  min-height: 44px;
  min-width: 44px;
}
.header-bell {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  position: relative;
}
.header-bell svg { width: 22px; height: 22px; }
.header-bell-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  background: var(--kikite-accent);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

/* ===== Tab Navigation ===== */
.tab-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: var(--tab-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  color: var(--text-secondary);
  transition: color 0.2s;
  position: relative;
}
.tab-item svg { width: 22px; height: 22px; }
.tab-item span { font-size: 10px; font-weight: 500; }
.tab-item.active { color: var(--kikite-primary); }
.tab-item.active span { font-weight: 700; }

/* 録音タブ（中央・特殊） */
.tab-item-record {
  position: relative;
  top: -8px;
}
.tab-item-record .tab-record-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--kikite-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(168,85,200,0.3);
}
.tab-item-record .tab-record-btn svg { width: 26px; height: 26px; color: #fff; }
.tab-item-record span { margin-top: 2px; }

/* ===== Page Container ===== */
.page {
  display: none;
  padding: 16px 20px;
  padding-bottom: calc(var(--tab-height) + 20px + env(safe-area-inset-bottom, 0));
  min-height: calc(100dvh - var(--header-height));
  animation: fadeIn 0.25s ease;
}
.page.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth pages — no tab nav padding */
.page-auth {
  padding-bottom: 40px;
  display: none;
  min-height: 100dvh;
}
.page-auth.active { display: flex; flex-direction: column; }

/* ===== Buttons ===== */
.btn-gradient {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  border-radius: var(--radius);
  background: var(--kikite-gradient);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  transition: opacity 0.2s;
  box-shadow: 0 4px 12px rgba(168,85,200,0.25);
}
.btn-gradient:hover { opacity: 0.9; }
.btn-gradient:active { transform: scale(0.98); }
.btn-gradient:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-outline:hover { background: var(--bg); }
.btn-outline:active { background: var(--border); }

.btn-text {
  color: var(--kikite-primary);
  font-size: 14px;
  font-weight: 500;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-text.subtle { color: var(--text-secondary); font-size: 13px; }
.btn-text.danger { color: var(--danger); }

.btn-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background 0.15s;
}
.btn-icon:hover { background: var(--bg); }
.btn-icon svg { width: 20px; height: 20px; }

.btn-sm {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-sm.copied { background: var(--success); color: #fff; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 12px; }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 16px;
  color: var(--text);
  -webkit-appearance: none;
  transition: border-color 0.2s;
}
.form-input:focus {
  outline: none;
  border-color: var(--kikite-primary);
  box-shadow: 0 0 0 3px rgba(168,85,200,0.1);
}
.form-input::placeholder { color: #B0B0C8; }
textarea.form-input { min-height: 80px; resize: vertical; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: #E6F7ED; color: #22753A; }
.badge-warning { background: #FFF3E6; color: #B45309; }

/* ===== Section ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title { font-size: 16px; font-weight: 700; }
.section-link { font-size: 13px; color: var(--kikite-primary); font-weight: 500; }

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
  margin-bottom: 12px;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}
.filter-chip:hover { background: var(--bg); }
.filter-chip:active { transform: scale(0.97); }
.filter-chip.active {
  background: var(--kikite-primary);
  border-color: var(--kikite-primary);
  color: #fff;
}
.filter-chip.active:hover { opacity: 0.9; background: var(--kikite-primary); }

/* ===== Session Card ===== */
.session-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.session-card + .session-card { margin-top: 8px; }
.session-card:active { background: var(--bg); }
.session-card-body { flex: 1; min-width: 0; }
.session-card-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-card-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.session-card-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.star-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #D0D0D8;
}
.star-btn.active { color: transparent; background: linear-gradient(135deg, #6B7FE3, #F0449A); -webkit-background-clip: text; background-clip: text; }

/* ===== Sort Bar ===== */
.sort-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 12px;
  gap: 8px;
}
.sort-select {
  font-size: 13px;
  color: var(--text-secondary);
  background: none;
  border: none;
  font-weight: 500;
  padding: 4px 0;
}

/* ===== Detail Page ===== */
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.detail-header-actions { display: flex; gap: 4px; }
.detail-customer { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.detail-meta { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }

.analysis-section { margin-bottom: 16px; }
.analysis-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--kikite-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.analysis-text { font-size: 14px; line-height: 1.7; color: var(--text); }

.transcript-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}
.transcript-content {
  display: none;
  padding: 12px 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
}
.transcript-content.open { display: block; }

/* ===== Recording ===== */
.record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  gap: 20px;
}
.record-btn-large {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--kikite-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(168,85,200,0.3);
  transition: transform 0.2s;
}
.record-btn-large:active { transform: scale(0.95); }
.record-btn-large svg { width: 48px; height: 48px; color: #fff; }
.record-label { font-size: 14px; color: var(--text-secondary); }

.record-stop-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(229,62,62,0.3);
}
.record-stop-btn svg { width: 28px; height: 28px; color: #fff; }

.record-timer {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.waveform-canvas {
  width: 100%;
  height: 80px;
}

.upload-area {
  width: 100%;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.upload-area:hover { border-color: var(--kikite-primary); }

/* ===== Report ===== */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
}
.month-nav-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.month-nav-label { font-size: 16px; font-weight: 600; }
.chart-container { position: relative; height: 200px; margin: 16px 0; }

/* ===== Settings ===== */
.settings-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--kikite-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  margin: 0 auto 16px;
}
.settings-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-child { border-bottom: none; }
.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 14px;
}
.settings-row-label { color: var(--text); }
.settings-row-value { color: var(--text-secondary); }

/* Toggle switch */
.toggle-switch {
  width: 44px;
  height: 24px;
  background: #D0D0D8;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-switch.on { background: var(--kikite-primary); }
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch.on::after { transform: translateX(20px); }

/* ===== Plan Card ===== */
.plan-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  border: 1.5px solid var(--border);
}
.plan-name { font-size: 14px; font-weight: 600; color: var(--kikite-primary); margin-bottom: 8px; }
.plan-meter { margin-bottom: 8px; }
.plan-meter-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; display: flex; justify-content: space-between; }
.plan-meter-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.plan-meter-fill { height: 100%; background: var(--kikite-gradient); border-radius: 3px; transition: width 0.4s; }

/* ===== Auth ===== */
.auth-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  background: linear-gradient(180deg, #F8F7FC 0%, #F0EDFB 100%);
}
.auth-logo { margin-bottom: 12px; }
.auth-logo img { height: 60px; }
.auth-tagline {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 40px;
}
.auth-form { width: 100%; max-width: 340px; }
.auth-form .form-group { margin-bottom: 14px; }
.auth-form .btn-gradient { margin-top: 8px; }
.auth-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}
.auth-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-bottom: 8px;
  min-height: 0;
}
.auth-error:empty { display: none; }
.auth-message {
  color: var(--success);
  font-size: 13px;
  text-align: center;
  margin-bottom: 8px;
  min-height: 0;
}
.auth-message:empty { display: none; }

/* ===== Post-record info ===== */
.record-info-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ===== Improvement Accordion ===== */
.imp-accordion summary { -webkit-user-select: none; user-select: none; }
.imp-accordion summary::-webkit-details-marker { display: none; }
.imp-accordion[open] summary .imp-chevron { transform: rotate(180deg); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,46,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(26,26,46,0.2);
}

/* ===== Utility ===== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
