/* ===== copytext.app — "Vivid Utility" (Stitch design) ===== */
@font-face {
  font-family: 'Zen Dots';
  src: url('zen_dots_regular.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('fonts/dmsans.woff2') format('woff2');
  font-weight: 100 1000;
  font-display: swap;
}

:root {
  --grad: linear-gradient(to bottom, #833AB4, #C13584, #E1306C, #F77737);
  --grad-btn: linear-gradient(to right, #833AB4 0%, #C13584 36%, #E1306C 66%, #F77737 100%);
  --bg: #FAFBFF;
  --card: #ffffff;
  --border: #D5DFFF;
  --primary: #a1166a;          /* лого + акценты */
  --magenta: #C13584;          /* контур вторичной кнопки */
  --on-surface: #1b1c1e;
  --on-surface-variant: #564149;
  --muted: #6b6b72;
  --error: #ba1a1a;
  --radius: 12px;              /* input / card */
  --radius-lg: 16px;          /* большие карточки */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px; line-height: 1.5;
  color: var(--on-surface);
  background: var(--bg);
  overscroll-behavior: none;
}
.hidden { display: none !important; }

/* ---------- SPLASH ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100;
  background: var(--grad);
  display: flex; flex-direction: column; justify-content: center;
  padding-left: 40px;
  opacity: 0; animation: fadeIn .8s ease forwards;
}
.splash.fade-out { animation: fadeOut .4s ease forwards; }
.splash-logo {
  font-family: 'Zen Dots', sans-serif; color: #fff;
  font-size: 52px; line-height: 1.15;
  display: flex; flex-direction: column;
}
.splash-credit {
  position: absolute; bottom: 44px; left: 0; right: 0; text-align: center;
  font-family: 'DM Sans', sans-serif; font-weight: 500;
  font-size: 13px; letter-spacing: .18em; text-transform: uppercase;
  color: rgba(255,255,255,.75);
}
@keyframes fadeIn  { to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }

/* ---------- APP SHELL ---------- */
.app { height: 100%; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 64px; flex: 0 0 auto;
  border-bottom: 1px solid rgba(193,53,132,.14);
  background: var(--bg);
}
.brand {
  font-family: 'Zen Dots', sans-serif; font-size: 20px;
  color: var(--primary); letter-spacing: -.01em; cursor: pointer;
}
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.topbar-actions { display: flex; align-items: center; gap: 2px; }
#accountBtn { position: relative; }
#accountAvatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: none; border-radius: 10px;
  background: transparent; color: var(--on-surface-variant); cursor: pointer;
  transition: transform .12s, background .12s;
}
.icon-btn:active { transform: scale(.92); background: rgba(0,0,0,.04); }

/* ---------- INPUT ---------- */
.main-body {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  padding: 32px 20px 20px;
  width: 100%; max-width: 640px; margin: 0 auto;
}
.field { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.field-label {
  font-size: 14px; font-weight: 500; letter-spacing: .01em;
  color: var(--on-surface-variant); padding-left: 4px;
}
#urlInput {
  width: 100%; min-height: 56px; padding: 0 20px;
  font-family: inherit; font-size: 18px; color: var(--on-surface);
  background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
#urlInput::placeholder { color: #9aa0b4; }
#urlInput:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(161,22,106,.15); }

/* ---------- BUTTONS ---------- */
.btn-primary, .btn-secondary {
  font-family: inherit; font-weight: 600; font-size: 17px; letter-spacing: .01em;
  border-radius: 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid transparent; transition: transform .12s, filter .12s, box-shadow .15s, background .12s;
}
.btn-primary {
  background: var(--grad-btn) border-box;   /* origin+clip = border-box: без заворота под прозрачным бордером */
  background-repeat: no-repeat;
  color: #fff;
  box-shadow: 0 4px 14px rgba(193,53,132,.20);
}
.btn-primary:hover { box-shadow: 0 6px 18px rgba(193,53,132,.26); }
.btn-primary:active { transform: scale(.98); filter: brightness(.97); }
.btn-secondary { background: var(--card); color: var(--magenta); border: 1.5px solid var(--magenta); }
.btn-secondary:active { transform: scale(.98); background: rgba(193,53,132,.06); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: .45; pointer-events: none; box-shadow: none; }
#getBtn { width: 100%; height: 58px; }

/* ---------- STATES ---------- */
.content { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  text-align: center; padding: 32px 8px;
}
.muted { color: var(--muted); font-size: 16px; line-height: 1.6; margin: 0; }
.error-text { color: var(--error); font-size: 16px; line-height: 1.55; white-space: pre-line; margin: 0; }

/* success card */
.result-card {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: 0 2px 10px rgba(131,58,180,.05);
}
.result-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex: 0 0 auto; }
.spark {
  width: 32px; height: 32px; border-radius: 50%; background: var(--grad);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.result-title { font-size: 14px; font-weight: 500; color: var(--on-surface-variant); }
#captionArea {
  flex: 1; width: 100%; border: none; outline: none; resize: none;
  font-family: inherit; font-size: 18px; line-height: 1.6;
  color: var(--on-surface); background: transparent; padding: 0;
}
.tap-hint {
  flex: 0 0 auto; text-align: center; margin-top: 12px;
  font-size: 12px; font-weight: 700; letter-spacing: .08em;
  color: var(--muted); opacity: .55;
}

/* ---------- BOTTOM BAR ---------- */
.bottom-bar {
  flex: 0 0 auto; display: flex; gap: 12px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--bg);
}
.bar-btn { flex: 1; height: 56px; font-size: 15px; }

/* ---------- LOADING OVERLAY ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(255,255,255,.82); backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 4px solid rgba(161,22,106,.2); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
.overlay-text { font-family: 'Zen Dots', sans-serif; font-size: 20px; color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- HISTORY ---------- */
.history-head {
  display: flex; align-items: center; gap: 6px; height: 64px; padding: 0 12px;
  border-bottom: 1px solid rgba(193,53,132,.14); flex: 0 0 auto;
}
.history-head h2 { font-family: 'Zen Dots', sans-serif; font-size: 20px; letter-spacing: -.01em; color: var(--primary); margin: 0; }
.history-list {
  flex: 1; overflow-y: auto;
  padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
  max-width: 640px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 16px;
}
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-date { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.card-actions { display: flex; gap: 2px; }
.card-actions .icon-btn { width: 36px; height: 36px; }
.card-actions .icon-btn svg { width: 19px; height: 19px; }
.card-preview {
  font-size: 18px; line-height: 1.55; color: var(--on-surface);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden; cursor: pointer; white-space: pre-wrap;
}
.danger { color: var(--error); }

/* ---------- MODAL ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(61,0,37,.35);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  position: relative; width: 100%; max-width: 560px; height: 88vh;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
  box-shadow: 0 -10px 40px rgba(131,58,180,.12);
  animation: slideUp .28s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal { height: 78vh; border-radius: 20px; animation: none; }
}
.modal-close { position: absolute; top: 10px; right: 10px; }
.modal-date { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 4px 0 14px; }
.modal-body { flex: 1; overflow-y: auto; min-height: 0; }
.modal-view { font-size: 18px; line-height: 1.6; white-space: pre-wrap; user-select: text; }
.modal-edit {
  flex: 1; width: 100%; resize: none;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; font-family: inherit; font-size: 18px; line-height: 1.6;
  outline: none; margin-bottom: 14px;
}
.modal-edit:focus { border-color: var(--primary); }
.modal-action { margin-top: 14px; width: 100%; height: 56px; font-size: 16px; }

/* ---------- ACCOUNT SHEET ---------- */
.sheet-auto { height: auto; max-height: 86vh; }
@media (min-width: 640px) { .sheet-auto { height: auto; } }
.account-pane {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 12px; padding: 8px 4px 4px;
}
.account-pane .muted { max-width: 320px; }
.spark-lg { width: 56px; height: 56px; margin-bottom: 4px; }
.spark-lg svg { width: 26px; height: 26px; }
.account-title { font-family: 'Zen Dots', sans-serif; font-size: 18px; color: var(--primary); margin: 4px 0 0; }
.acc-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.gbtn-wrap { margin-top: 8px; min-height: 44px; display: flex; justify-content: center; }

/* ---------- CONFIRM DIALOG ---------- */
.confirm-card {
  width: 100%; max-width: 380px; margin: 20px;
  background: var(--card); border-radius: var(--radius-lg); padding: 24px;
  box-shadow: 0 12px 40px rgba(131,58,180,.18);
}
.confirm-msg { font-size: 17px; line-height: 1.5; margin: 0 0 20px; text-align: center; }
.confirm-actions { display: flex; gap: 12px; }
.confirm-actions button { flex: 1; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #2f3032; color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 500; z-index: 200; opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }
