@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #12181b;
  --surface: #1b2328;
  --surface-2: #222b31;
  --line: #2c363c;
  --text: #ede9e0;
  --text-dim: #9aa6a8;
  --accent: #c9a15a;
  --accent-soft: #c9a15a22;
  --teal: #5b8c82;
  --danger: #c0564b;
  --radius: 14px;
  font-size: 16px;
}

/* ---- Темы для публичной страницы ---- */
body[data-theme="porcelain"] {
  --bg: #f3efe6;
  --surface: #ffffff;
  --surface-2: #ece5d6;
  --line: #ddd3bd;
  --text: #241f18;
  --text-dim: #7a7062;
  --accent: #2f6e64;
  --accent-soft: #2f6e6422;
}

body[data-theme="forest"] {
  --bg: #10190f;
  --surface: #182617;
  --surface-2: #1f301d;
  --line: #2c3d29;
  --text: #eef2e6;
  --text-dim: #9db096;
  --accent: #d8a24a;
  --accent-soft: #d8a24a22;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
}

a { color: inherit; }

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

::selection { background: var(--accent-soft); }

/* focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------- Auth tabs (login/register) ---------------- */

.auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 9px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 500;
}
.auth-tab.active { background: var(--surface); color: var(--text); }

.auth-form { display: none; }
.auth-form.active { display: block; }

/* ---------------- Public link page ---------------- */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 32px;
  background: var(--bg);
  position: relative;
}

.cover {
  width: 100%;
  height: 340px;
  background: linear-gradient(135deg, var(--surface-2), var(--bg) 70%);
  background-size: cover;
  background-position: center;
}

.card {
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 24px;
  margin-top: -80px;
}

.avatar {
  width: 152px;
  height: 152px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 4px solid var(--bg);
  margin-bottom: 24px;
}

.avatar.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', serif;
  font-size: 3.2rem;
  color: var(--text-dim);
}

.name {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 2.6rem;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}

.bio {
  color: var(--text-dim);
  line-height: 1.5;
  max-width: 50ch;
  margin: 0 0 40px;
  font-size: 1.05rem;
}

.links {
  width: 100%;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.link-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 8px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s ease, padding-left 0.15s ease;
}

.link-row:hover {
  background: var(--surface);
  padding-left: 14px;
}

.link-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  color: var(--accent);
}

.icon-wrap {
  display: flex;
  flex-shrink: 0;
}
.icon-wrap.blurred svg {
  filter: blur(3px);
  opacity: 0.55;
}

.tag-18 {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  color: #fff;
  background: var(--danger);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.link-title {
  font-weight: 500;
  font-size: 1.05rem;
  flex: 1;
  text-align: left;
}

.link-arrow {
  color: var(--text-dim);
  font-size: 1.1rem;
}

.empty-state {
  color: var(--text-dim);
  padding: 24px 0;
  font-size: 0.95rem;
}

.footer-note {
  margin-top: 48px;
  font-size: 0.8rem;
}

.corner-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
  display: flex;
  gap: 8px;
}

.corner-btn {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 7px 14px;
  border-radius: 20px;
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
}
.corner-btn:hover { color: var(--text); border-color: var(--accent); }
.corner-btn.is-accent { color: var(--accent); border-color: var(--accent); }

.field {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="url"],
.field textarea,
.field select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.checkbox-row input { accent-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: #1a1305;
  width: 100%;
}
.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-secondary:hover { border-color: var(--accent); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.form-error {
  background: #c0564b1a;
  border: 1px solid var(--danger);
  color: #e8a49c;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: none;
}
.form-error.visible { display: block; }

/* ---------------- Modal (профиль / переводчик / вход) ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 100;
}

.modal-box {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-box h2 {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 1.4rem;
  margin: 0 0 4px;
}
.modal-box .section-sub {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin: 0 0 22px;
}

.tab-btn {
  text-align: left;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.tab-btn:hover { background: var(--surface-2); color: var(--text); }
.tab-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.modal-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.panel { display: none; }
.panel.active { display: block; }

.cover-editor-preview {
  width: 100%;
  height: 110px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--surface-2), var(--bg) 70%);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--line);
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}
.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.pos-slider {
  width: 100%;
  margin-top: 8px;
  accent-color: var(--accent);
}
.pos-slider-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 6px;
  display: block;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.color-grid .field { margin-bottom: 0; }
.color-grid input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.link-editor-row {
  display: grid;
  grid-template-columns: 120px 1fr 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 10px;
}

.sensitive-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  cursor: pointer;
}
.sensitive-toggle input { accent-color: var(--danger); }

.link-editor-row select,
.link-editor-row input {
  width: 100%;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--danger); border-color: var(--danger); }

.icon-upload-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
}
.icon-upload-btn img { width: 100%; height: 100%; object-fit: cover; }
.icon-upload-btn:hover { border-color: var(--accent); }

.add-link-btn {
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--text-dim);
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 24px;
}
.add-link-btn:hover { border-color: var(--accent); color: var(--accent); }

.save-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.save-status {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Translator */
.translate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.translate-grid textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  color: var(--text);
  line-height: 1.5;
}
.translate-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}

.badge-wip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 40px;
  border-radius: var(--radius);
  justify-content: center;
  font-size: 0.95rem;
  flex-direction: column;
  text-align: center;
}
.badge-wip strong { color: var(--text); font-family: 'Fraunces', serif; font-weight: 500; font-size: 1.1rem; }

@media (max-width: 720px) {
  .modal-box { padding: 20px; max-width: 100%; }
  .modal-tabs { flex-direction: column; }
  .translate-grid { grid-template-columns: 1fr; }
  .link-editor-row { grid-template-columns: 1fr; }
  .color-grid { grid-template-columns: 1fr; }
  .card { max-width: 100%; padding: 0 16px; }
  .cover { height: 220px; }
  .avatar { width: 110px; height: 110px; }
}

/* ---------------- Полноэкранный переводчик ---------------- */

.tr-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.tr-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.tr-back {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.tr-back:hover { color: var(--text); }

.tr-header-tabs {
  display: flex;
  gap: 6px;
}
.tr-tab {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}
.tr-tab:hover { background: var(--surface-2); color: var(--text); }
.tr-tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.tr-header-spacer { flex: 1; }

.tr-lang-bar {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.tr-lang-side {
  flex: 1;
  padding: 14px 28px;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.tr-swap-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  margin: 0 -19px;
  z-index: 2;
  background-clip: padding-box;
}
.tr-swap-btn:hover { color: var(--accent); border-color: var(--accent); }

.tr-lang-select {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 14px 28px;
  font-size: 0.9rem;
  cursor: pointer;
}

.tr-panel { display: none; flex: 1; }
.tr-panel.active { display: flex; flex-direction: column; }

.tr-columns {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.tr-col {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tr-col:first-child { border-right: 1px solid var(--line); }

.tr-icon-btn {
  position: absolute;
  top: 14px;
  right: 18px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tr-icon-btn:hover { color: var(--accent); border-color: var(--accent); }

.tr-textarea {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 1.5rem;
  line-height: 1.6;
  padding: 60px 28px 28px;
}

.tr-result {
  white-space: pre-wrap;
  overflow-y: auto;
}

.tr-status {
  padding: 10px 28px;
  font-size: 0.85rem;
  color: var(--text-dim);
  border-top: 1px solid var(--line);
  min-height: 38px;
}

.tr-denied {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--text-dim);
  background: var(--bg);
}

@media (max-width: 720px) {
  .tr-columns { grid-template-columns: 1fr; }
  .tr-col:first-child { border-right: none; border-bottom: 1px solid var(--line); }
  .tr-textarea { font-size: 1.15rem; padding: 54px 18px 18px; }
  .tr-header { flex-wrap: wrap; padding: 12px 16px; gap: 12px; }
  .tr-lang-side, .tr-lang-select { padding: 12px 16px; font-size: 0.85rem; }
}
