/* ═══════════════════════════════════════════════════
   StepOz App UI V2.2
   4 entries · task grid · receipt · emergency float
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --navy:          #0d3553;
  --navy-deep:     #08243a;
  --navy-light:    rgba(13, 53, 83, 0.08);
  --navy-mid:      rgba(13, 53, 83, 0.55);
  --orange:        #f4762a;
  --orange-deep:   #dc5e16;
  --orange-tint:   rgba(244, 118, 42, 0.09);
  --green:         #2a7b5c;
  --green-tint:    rgba(42, 123, 92, 0.08);
  --green-border:  rgba(42, 123, 92, 0.18);

  --bg-page:       #f9f4ed;
  --bg-warm:       #fffcf8;
  --bg-card:       #ffffff;
  --bg-card-alt:   rgba(249, 246, 242, 0.7);

  --text:          #1a1614;
  --text-mid:      #5a4f47;
  --text-light:    #9e8f87;

  --border:        rgba(13, 53, 83, 0.09);
  --border-warm:   rgba(180, 155, 130, 0.22);

  --serif: "Playfair Display", "Iowan Old Style", Georgia, "Songti SC", serif;
  --sans:  "Inter", "SF Pro Text", "PingFang SC", "Hiragino Sans GB", sans-serif;

  --sh-1: 0 1px 4px rgba(13,40,70,0.04), 0 2px 10px rgba(13,40,70,0.04);
  --sh-2: 0 4px 16px rgba(13,40,70,0.07), 0 8px 28px rgba(13,40,70,0.05);

  --r-sm: 14px;
  --r-md: 20px;
  --r-lg: 24px;
  --r-xl: 32px;
  --r-full: 999px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t: 180ms var(--ease);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(ellipse at 0% 0%, rgba(244, 118, 42, 0.05) 0%, transparent 40%),
    linear-gradient(180deg, var(--bg-warm) 0%, var(--bg-page) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }

/* ── App shell ──────────────────────────────────────── */
.app {
  max-width: 540px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────── */
.app-header {
  padding: 18px 24px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 253, 250, 0.94);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 34px;
  height: 26px;
  object-fit: contain;
}

.app-brand-name {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-lang-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: var(--r-full);
  background: var(--navy-light);
  color: var(--navy);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t);
}

.app-lang-tag:hover {
  background: rgba(13, 53, 83, 0.14);
}

.app-status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border-radius: var(--r-full);
  border: 1px solid var(--border-warm);
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.79rem;
  color: var(--text-mid);
}

.app-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* ── Main ───────────────────────────────────────────── */
.app-main {
  flex: 1;
  padding: 24px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-bottom: 160px;
}

/* ── Back link ──────────────────────────────────────── */
.app-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--text-light);
  transition: color var(--t);
}
.app-back:hover { color: var(--navy); }

/* ── Greeting ───────────────────────────────────────── */
.app-greeting { display: grid; gap: 5px; }

.app-greeting h1 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.app-greeting p {
  font-size: 0.93rem;
  color: var(--text-mid);
}

/* ── Section label ──────────────────────────────────── */
.app-section-label {
  font-size: 0.69rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--orange-deep);
  font-weight: 700;
  margin-bottom: 10px;
}

/* ── V2.2 Entry Grid (4 big entries) ────────────────── */
.app-entry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.entry-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 20px 18px 18px;
  border-radius: var(--r-lg);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  box-shadow: var(--sh-1);
  cursor: pointer;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
  text-align: left;
}

.entry-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-2);
}

.entry-btn:active {
  transform: scale(0.97);
}

/* accent variants */
.entry-btn.accent-orange { border-color: rgba(244, 118, 42, 0.2); }
.entry-btn.accent-orange:hover { border-color: rgba(244, 118, 42, 0.38); }

.entry-btn.accent-navy { border-color: rgba(13, 53, 83, 0.18); }
.entry-btn.accent-navy:hover { border-color: rgba(13, 53, 83, 0.3); }

.entry-btn.accent-warm { border-color: rgba(180, 130, 80, 0.22); }
.entry-btn.accent-warm:hover { border-color: rgba(180, 130, 80, 0.38); }

.entry-btn.accent-green { border-color: var(--green-border); }
.entry-btn.accent-green:hover { border-color: rgba(42, 123, 92, 0.3); }

.entry-icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 6px;
}

.entry-title {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.entry-sub {
  font-size: 0.71rem;
  color: var(--text-light);
  line-height: 1.45;
}

.entry-arrow {
  position: absolute;
  bottom: 14px;
  right: 16px;
  font-size: 0.75rem;
  color: var(--text-light);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--t), transform var(--t);
}

.entry-btn:hover .entry-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* ── Tasks remaining pill ───────────────────────────── */
.tasks-remaining-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  align-self: center;
  padding: 5px 16px;
  background: rgba(42, 123, 92, 0.08);
  border: 1px solid rgba(42, 123, 92, 0.22);
  border-radius: var(--r-full);
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--green);
  width: fit-content;
}

.app-registration-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: var(--r-xl);
  border: 1px solid rgba(13, 53, 83, 0.12);
  background:
    radial-gradient(circle at top right, rgba(244, 118, 42, 0.13), transparent 34%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 248, 239, 0.9));
  box-shadow: var(--sh-2);
}

.app-registration-copy {
  display: grid;
  gap: 6px;
}

.app-registration-eyebrow {
  color: var(--orange-deep);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.app-registration-copy h2 {
  color: var(--navy);
  font-family: var(--serif);
  font-size: clamp(1.3rem, 4vw, 1.82rem);
  line-height: 1.16;
  letter-spacing: -0.025em;
}

.app-registration-copy p:not(.app-registration-eyebrow),
.app-registration-proof {
  color: var(--text-mid);
  font-size: 0.9rem;
  line-height: 1.65;
}

.app-registration-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-registration-primary,
.app-registration-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: var(--r-full);
  font-size: 0.9rem;
  font-weight: 800;
  transition: transform var(--t), box-shadow var(--t), background var(--t);
}

.app-registration-primary {
  color: #fffaf3;
  background: linear-gradient(135deg, var(--orange), var(--orange-deep));
  box-shadow: 0 10px 22px rgba(244, 118, 42, 0.18);
}

.app-registration-secondary {
  color: var(--navy);
  background: rgba(13, 53, 83, 0.06);
  border: 1px solid rgba(13, 53, 83, 0.1);
}

.app-registration-primary:hover,
.app-registration-secondary:hover {
  transform: translateY(-1px);
}

.app-registration-proof {
  padding-top: 2px;
  color: var(--green);
  font-weight: 700;
}

/* ── Task grid (3×2) ────────────────────────────────── */
.task-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.task-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 14px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--t), box-shadow var(--t), transform 0.12s;
}

.task-card:hover {
  border-color: rgba(244, 118, 42, 0.4);
  box-shadow: 0 2px 12px rgba(244, 118, 42, 0.1);
  transform: translateY(-1px);
}

.task-card:active {
  transform: scale(0.97);
}

.task-icon {
  font-size: 1.3rem;
  line-height: 1;
  margin-bottom: 4px;
}

.task-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.task-desc {
  font-size: 0.68rem;
  color: var(--text-light);
  line-height: 1.4;
}

.task-cap {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 3px;
}

/* ── Divider ────────────────────────────────────────── */
.app-divider {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-divider span {
  font-size: 0.79rem;
  color: var(--text-light);
  white-space: nowrap;
}

.app-divider::before,
.app-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-warm);
}

/* ── Chat area ──────────────────────────────────────── */
.chat-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 40px;
}

.chat-bubble {
  max-width: 84%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.68;
  white-space: pre-wrap;
}

.chat-bubble.user {
  background: var(--navy);
  color: #fff9f3;
  align-self: flex-end;
  border-radius: 18px 18px 4px 18px;
}

.chat-bubble.assistant {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px 18px 18px 18px;
  align-self: flex-start;
  box-shadow: var(--sh-1);
}

/* ── V2.2 Task receipt ──────────────────────────────── */
.task-receipt {
  border-radius: var(--r-lg);
  background: var(--bg-card);
  border: 1.5px solid var(--green-border);
  box-shadow: 0 2px 16px rgba(42, 123, 92, 0.12), var(--sh-1);
  overflow: hidden;
  margin-top: 6px;
}

.receipt-header {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, rgba(42,123,92,0.1) 0%, rgba(42,123,92,0.04) 100%);
  border-bottom: 1px solid var(--green-border);
}

.receipt-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.receipt-header-text { flex: 1; display: grid; gap: 2px; }

.receipt-title {
  font-size: 0.93rem;
  font-weight: 700;
  color: var(--green);
  line-height: 1.3;
}

.receipt-meta {
  font-size: 0.77rem;
  color: var(--text-mid);
}

.receipt-body {
  padding: 14px 18px 16px;
  display: grid;
  gap: 10px;
}

.receipt-label {
  font-size: 0.69rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-light);
  font-weight: 700;
}

.receipt-items {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.receipt-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--r-full);
  background: var(--green-tint);
  border: 1px solid var(--green-border);
  font-size: 0.79rem;
  color: var(--green);
  font-weight: 600;
}

.receipt-item::before {
  content: '✓';
  font-size: 0.72rem;
  font-weight: 700;
}

.receipt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 0 18px 16px;
}

.receipt-btn {
  flex: 1;
  min-width: 120px;
  padding: 11px 16px;
  border-radius: var(--r-full);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform var(--t), background var(--t);
  text-align: center;
}

.receipt-btn.primary {
  background: var(--green);
  color: #fff;
}

.receipt-btn.primary:hover {
  background: #1e6047;
  transform: scale(1.02);
}

.receipt-btn.secondary {
  background: var(--navy-light);
  color: var(--navy);
  border: 1px solid var(--border);
}

.receipt-btn.secondary:hover {
  background: rgba(13, 53, 83, 0.14);
  transform: scale(1.02);
}

.receipt-synced {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px 14px;
  color: var(--green);
  font-size: 0.84rem;
  font-weight: 600;
  border-top: 1px solid var(--green-border);
  background: var(--green-tint);
}

/* ── V2.2 Emergency float button ────────────────────── */
.emergency-float {
  position: fixed;
  bottom: 108px;
  right: 20px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: var(--r-full);
  background: #c0392b;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 16px rgba(192, 57, 43, 0.38), 0 2px 8px rgba(192, 57, 43, 0.25);
  cursor: pointer;
  border: none;
  transition: transform var(--t), box-shadow var(--t);
  animation: e-pulse 3.5s ease-in-out infinite;
}

.emergency-float:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 22px rgba(192, 57, 43, 0.52);
  animation: none;
}

.emergency-float:active {
  transform: scale(0.97);
}

@keyframes e-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(192,57,43,0.38), 0 2px 8px rgba(192,57,43,0.25); }
  50%       { box-shadow: 0 4px 22px rgba(192,57,43,0.56), 0 2px 8px rgba(192,57,43,0.3); }
}

/* ── Ghost prompt ───────────────────────────────────── */
.app-ghost-prompt {
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 8px;
  line-height: 1.5;
  opacity: 0.8;
  transition: opacity var(--t);
}

/* ── Sticky input ───────────────────────────────────── */
.app-input-wrap {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 540px;
  padding: 14px 20px 28px;
  background: rgba(255, 253, 250, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  z-index: 20;
}

.app-input-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--r-xl);
  background: var(--bg-card);
  border: 1.5px solid var(--border-warm);
  box-shadow: var(--sh-1);
  transition: border-color var(--t), box-shadow var(--t);
}

.app-input-row:focus-within {
  border-color: rgba(13, 53, 83, 0.2);
  box-shadow: 0 0 0 3px rgba(13, 53, 83, 0.05), var(--sh-1);
}

.app-textarea {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  font: inherit;
  font-size: 0.93rem;
  line-height: 1.6;
  color: var(--text);
  background: transparent;
  min-height: 24px;
  max-height: 120px;
  overflow-y: auto;
}

.app-textarea::placeholder { color: var(--text-light); }

.app-input-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.app-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--t), background var(--t);
}

.app-btn:hover { transform: scale(1.08); }

.app-btn-camera {
  background: var(--navy-light);
  color: var(--text-mid);
}

.app-btn-send {
  background: var(--navy);
}

.app-btn-send:hover { background: var(--navy-deep); }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 540px) {
  .app { max-width: 100%; }
  .app-main { padding: 20px 16px 0; padding-bottom: 156px; }
  .app-input-wrap { padding: 12px 16px 24px; }
  .emergency-float { bottom: 100px; right: 16px; padding: 9px 15px; font-size: 0.77rem; }
}

@media (max-width: 400px) {
  .app-entry-grid { gap: 9px; }
  .entry-btn { padding: 16px 14px 14px; }
  .entry-icon { font-size: 1.75rem; }
  .entry-title { font-size: 0.93rem; }
  .entry-sub { font-size: 0.67rem; }
  .task-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════════════════
   LANGUAGE SWITCHER  (app page variant)
   ═══════════════════════════════════════════════════ */

.ls-wrap { position: relative; }

.ls-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: transparent;
  cursor: pointer; font-family: var(--sans); font-size: 0.75rem;
  color: var(--text-mid); transition: background 140ms;
}
.ls-btn:hover { background: var(--green-tint); border-color: var(--green-border); }
.ls-globe { font-size: 0.8rem; }
.ls-cur   { font-weight: 600; }
.ls-caret { font-size: 0.6rem; opacity: 0.55; }

.ls-menu {
  display: none;
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 170px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: 0 8px 28px rgba(13,40,70,0.12); z-index: 200;
  overflow: hidden; padding: 6px;
}
.ls-menu.open { display: block; }

.ls-option {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; border-radius: 10px;
  text-decoration: none; color: var(--text-mid);
  font-size: 0.8rem; transition: background 120ms;
}
.ls-option:hover  { background: #f5f1ec; }
.ls-option.active { color: var(--green); font-weight: 600; background: var(--green-tint); }
.ls-flag  { font-size: 1rem; flex-shrink: 0; }
.ls-name  { flex: 1; }
.ls-check { font-size: 0.7rem; color: var(--green); }

/* ═══════════════════════════════════════════════════
   RTL SUPPORT  (app page)
   ═══════════════════════════════════════════════════ */

[dir="rtl"] .app              { direction: rtl; }
[dir="rtl"] .app-header       { direction: rtl; }
[dir="rtl"] .app-greeting     { text-align: right; }
[dir="rtl"] .app-section-label { text-align: right; }
[dir="rtl"] .entry-btn        { text-align: right; align-items: flex-end; }
[dir="rtl"] .entry-arrow      { transform: scaleX(-1); }
[dir="rtl"] .task-card        { align-items: flex-end; text-align: right; }
[dir="rtl"] .app-back         { direction: rtl; }
[dir="rtl"] .app-input-row    { flex-direction: row-reverse; }
[dir="rtl"] .chat-bubble.user { align-self: flex-start; }
[dir="rtl"] .chat-bubble.assistant { align-self: flex-end; }
[dir="rtl"] .receipt-header   { direction: rtl; }
[dir="rtl"] .ls-menu          { right: auto; left: 0; }
