:root {
  --primary: #4A738C;
  --primary-dark: #3b5c70;
  --primary-soft: #eef3f6;
  --accent: #C79A2B;
  --accent-dark: #a07b22;
  --text: #4D4D4D;
  --muted: #8a8a8a;
  --line: #e5e5e5;
  --bg: #FAFAFA;
  --card: #ffffff;
  --ok: #16a34a;
  --err: #dc2626;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: 'Inter', -apple-system, system-ui, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
button, select, a { font-family: inherit; }

/* Reveal and motion */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.reveal { animation: rise .45s var(--ease) both; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Login */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% 10%, #5d8aa5 0%, transparent 60%), linear-gradient(135deg, #1e2e38, var(--primary)); }
.login-card { background: var(--card); width: 100%; max-width: 400px; border-radius: 20px; padding: 36px 32px; text-align: center; box-shadow: 0 30px 60px rgba(0,0,0,.25); }
.login-logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 14px; animation: pop .6s var(--ease) both; }
.login-card h1 { font-size: 22px; color: #1e2e38; margin-bottom: 6px; }
.login-card .muted { font-size: 14px; margin-bottom: 22px; }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; border: 1px solid #d4d4d4; border-radius: 12px;
  color: #333; text-decoration: none; font-weight: 500; font-size: 14px; transition: all .2s var(--ease); margin-bottom: 16px; }
.google-btn:hover { background: #f7f7f7; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.08); }
.google-btn:active { transform: translateY(0); }

/* Shell */
.app { height: 100%; display: flex; flex-direction: column; animation: fade .3s ease both; }
.toolbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--primary); color: #fff; flex-wrap: wrap; }
.title { font-weight: 700; font-size: 16px; }
.controls { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.toolbar select { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); padding: 7px 12px; border-radius: 8px; font-size: 13px; cursor: pointer; outline: none; transition: background .2s; }
.toolbar select:hover { background: rgba(255,255,255,.25); }
.toolbar select option { background: var(--primary); }
.swap-btn { background: rgba(255,255,255,.2); border: none; color: #fff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 18px; transition: background .2s, transform .45s var(--ease); }
.swap-btn:hover { background: rgba(255,255,255,.35); }
.swap-btn.spin { transform: rotate(180deg); }

.tabs { position: relative; display: flex; background: rgba(0,0,0,.15); border-radius: 10px; padding: 3px; }
.tab { position: relative; z-index: 1; background: none; border: none; color: rgba(255,255,255,.75); padding: 6px 16px; font-size: 13px; font-weight: 600; cursor: pointer; transition: color .2s; }
.tab.active, .tab:hover { color: #fff; }
.tab-ink { position: absolute; top: 3px; bottom: 3px; left: 3px; border-radius: 8px; background: rgba(255,255,255,.22); transition: transform .35s var(--ease), width .35s var(--ease); }

.user { display: flex; align-items: center; gap: 8px; }
.user img { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); transition: transform .2s; }
.user img:hover { transform: scale(1.1); }
.toolbar .ghost-btn { color: #fff; border-color: rgba(255,255,255,.35); }
.toolbar .ghost-btn:hover { background: rgba(255,255,255,.15); color: #fff; border-color: #fff; }

/* Text tab */
.main { flex: 1; display: flex; overflow: hidden; animation: fade .3s ease both; }
.panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.panel:first-child { border-right: 1px solid var(--line); }
.panel-header { padding: 10px 16px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--primary); background: #fff; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; min-height: 42px; }
.char-count { font-weight: 400; color: #a3a3a3; text-transform: none; letter-spacing: 0; transition: color .2s; }
.char-count.over { color: var(--err); font-weight: 600; }
textarea { flex: 1; border: none; padding: 16px; font-size: 15px; line-height: 1.6; resize: none; outline: none; font-family: inherit; color: var(--text); background: #fff; }
textarea::placeholder { color: #a3a3a3; }
.output-area { flex: 1; padding: 16px; font-size: 15px; line-height: 1.6; background: #fff; overflow-y: auto; white-space: pre-wrap; }
.output-area.placeholder { color: #a3a3a3; font-style: italic; }
.output-area.loading { animation: pulse 1.5s infinite; }
.output-area.fresh { animation: rise .35s var(--ease) both; }
.output-area.error { color: var(--err); }

.bottom-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; background: #fff; border-top: 1px solid var(--line); }
.status { font-size: 12px; color: #a3a3a3; }

/* Buttons */
.primary-btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--accent); color: #fff; border: none; padding: 11px 32px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .2s, transform .15s var(--ease), box-shadow .2s; }
.primary-btn:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 8px 18px rgba(199,154,43,.3); }
.primary-btn:active { transform: translateY(1px) scale(.98); }
.primary-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.primary-btn.loading { background: linear-gradient(90deg, var(--primary) 0%, #6b93ab 50%, var(--primary) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.primary-btn.wide { width: 100%; }
.ghost-btn { background: none; border: 1px solid var(--line); color: var(--text); padding: 6px 14px; border-radius: 8px; font-size: 12px; cursor: pointer; transition: all .2s; }
.ghost-btn:hover { border-color: var(--primary); color: var(--primary); }
.copy-btn { background: none; border: 1px solid var(--line); color: var(--text); padding: 5px 14px; border-radius: 6px; font-size: 12px; cursor: pointer; transition: all .2s; text-transform: none; letter-spacing: 0; }
.copy-btn:hover { border-color: var(--primary); color: var(--primary); }
.copy-btn.copied { border-color: var(--ok); color: var(--ok); }

/* Document tab */
.doc { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 40px 16px; animation: fade .3s ease both; }
.dropzone { width: 100%; max-width: 620px; border: 2px dashed #c9d6de; border-radius: 20px; background: #fff; padding: 48px 24px; text-align: center; cursor: pointer; transition: all .25s var(--ease); outline: none; }
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); box-shadow: 0 12px 30px rgba(74,115,140,.12); transform: translateY(-2px); }
.dropzone.over { border-color: var(--accent); background: #fdf8eb; transform: scale(1.02); }
.dropzone.over .drop-icon { animation: bob .8s ease-in-out infinite; color: var(--accent); }
.drop-icon { width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; transition: color .2s; }
.dropzone h2 { font-size: 18px; color: #1e2e38; margin-bottom: 6px; }
.dropzone .link { color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.dropzone .tiny { margin-top: 14px; line-height: 1.6; }

.card { width: 100%; max-width: 620px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: 0 6px 20px rgba(0,0,0,.04); }
.file-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.file-badge { width: 52px; height: 52px; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; animation: pop .45s var(--ease) both; }
.file-meta { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.file-meta strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #1e2e38; }
.card > .tiny { margin-bottom: 16px; line-height: 1.6; }

.progress-head { display: flex; justify-content: space-between; margin-bottom: 12px; color: #1e2e38; }
.progress-head span { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--primary); }
.progress { height: 10px; background: var(--primary-soft); border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; transition: width .6s var(--ease);
  background: linear-gradient(90deg, var(--primary), #79a3bb, var(--accent), var(--primary)); background-size: 300% 100%; animation: shimmer 2.5s linear infinite; }

.done { text-align: center; }
.done h2 { color: #1e2e38; margin: 8px 0 4px; }
.done .muted { margin-bottom: 18px; font-size: 14px; }
.done .ghost-btn { margin-top: 10px; }
.check { width: 64px; height: 64px; margin: 0 auto; animation: pop .5s var(--ease) both; }
.check svg { width: 100%; height: 100%; fill: none; stroke: var(--ok); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.check circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw .6s var(--ease) .1s forwards; }
.check path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .4s var(--ease) .6s forwards; }

.alert { width: 100%; max-width: 620px; padding: 12px 14px; border-radius: 10px; background: #fef2f2; border: 1px solid #fecaca; color: var(--err); font-size: 14px; margin-bottom: 14px; animation: rise .3s var(--ease) both; text-align: left; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #1e2e38; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: all .3s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .toolbar { padding: 10px 16px; gap: 10px; }
  .controls { margin-left: 0; width: 100%; order: 3; }
  .controls select { flex: 1; min-width: 0; }
  .user { margin-left: auto; }
  .main { flex-direction: column; }
  .panel:first-child { border-right: none; border-bottom: 1px solid var(--line); }
  .doc { padding: 24px 16px; }
}
