/* style.css — PostMark */

/* ========= DARK THEME (default) ========= */
:root,
[data-theme="dark"] {
  --bg:        #0e0f11;
  --bg2:       #141518;
  --bg3:       #1b1d22;
  --border:    #2a2d35;
  --border2:   #3a3e4a;
  --text:      #e8eaf0;
  --text2:     #9095a8;
  --text3:     #5c6078;
  --accent:    #4f7cff;
  --accent2:   #3a60e8;
  --accent-glow: rgba(79,124,255,.18);
  --success:   #22c97a;
  --success-bg:#0d2e1f;
  --error:     #ff5757;
  --error-bg:  #2e0d0d;
  --warn:      #ffb84f;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
  --wm-checker1: #2a2d35;
  --wm-checker2: transparent;
  --preview-bg1: #1b1d22;
  --preview-bg2: #141518;
}

/* ========= LIGHT THEME ========= */
[data-theme="light"] {
  --bg:        #f4f5f7;
  --bg2:       #ffffff;
  --bg3:       #f0f1f4;
  --border:    #dde0e8;
  --border2:   #c5c9d6;
  --text:      #1a1c24;
  --text2:     #5a6070;
  --text3:     #9098b0;
  --accent:    #4f7cff;
  --accent2:   #3a60e8;
  --accent-glow: rgba(79,124,255,.12);
  --success:   #18a765;
  --success-bg:#edfaf3;
  --error:     #e03535;
  --error-bg:  #fdeaea;
  --warn:      #d48000;
  --shadow:    0 4px 24px rgba(0,0,0,.08);
  --wm-checker1: #d0d3dc;
  --wm-checker2: transparent;
  --preview-bg1: #e0e3eb;
  --preview-bg2: #f0f1f4;
}

/* ========= BASE ========= */
--radius:    12px;
--radius-sm: 8px;
--transition: .18s cubic-bezier(.4,0,.2,1);
--font-display: 'Syne', sans-serif;
--font-body:    'DM Sans', sans-serif;

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}

/* ========= LAYOUT ========= */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ========= SIDEBAR ========= */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: background .2s, border-color .2s;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 2rem;
  padding: 0 .5rem;
}

.logo-mark {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: .85rem;
  background: var(--accent);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  letter-spacing: .02em;
  flex-shrink: 0;
}

.logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: -.01em;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  flex: 1;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  border-radius: 8px;
  color: var(--text2);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: all .18s cubic-bezier(.4,0,.2,1);
}

.nav-item a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .7;
}

.nav-item a:hover {
  background: var(--bg3);
  color: var(--text);
}

.nav-item.active a {
  background: var(--accent-glow);
  color: var(--accent);
}

.nav-item.active a svg { opacity: 1; }

/* ========= SIDEBAR BOTTOM ========= */
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: auto;
  padding-top: 1rem;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .75rem;
  font-size: .8rem;
  color: var(--text3);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--text3); }

/* ========= THEME TOGGLE ========= */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .75rem;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: .88rem;
  font-weight: 500;
  transition: all .18s cubic-bezier(.4,0,.2,1);
  width: 100%;
}

.theme-toggle:hover {
  background: var(--bg3);
  border-color: var(--border2);
  color: var(--text);
}

.theme-label { flex: 1; text-align: left; }

/* Sun/moon visibility based on theme */
[data-theme="dark"]  .theme-icon-dark  { display: none; }
[data-theme="dark"]  .theme-icon-light { display: flex; }
[data-theme="light"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark  { display: flex; }

.theme-icon { align-items: center; }

/* Header theme toggle (shown on mobile/tablet) */
.theme-toggle-header {
  width: 42px;
  height: 42px;
  padding: 0;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
}

/* ========= MAIN CONTENT ========= */
.main-content {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1000px;
  overflow-x: hidden;
}

.page-header {
  margin-bottom: 2rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.page-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  line-height: 1.2;
}

.page-subtitle {
  margin-top: .3rem;
  color: var(--text2);
  font-size: .9rem;
  font-weight: 300;
}

/* ========= ALERTS ========= */
.alert {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1.1rem;
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 1.5rem;
  border: 1px solid transparent;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(34,201,122,.2); }
.alert-error   { background: var(--error-bg); color: var(--error); border-color: rgba(255,87,87,.2); }

/* ========= CARD ========= */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: border-color .18s, background .2s;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-header h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

.badge {
  font-size: .75rem;
  padding: .2rem .6rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text2);
}

.link-small {
  font-size: .8rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.link-small:hover { text-decoration: underline; }

/* ========= FORM GRID ========= */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.25rem;
  align-items: start;
}

.side-cards {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ========= UPLOAD ZONE ========= */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: 12px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all .18s cubic-bezier(.4,0,.2,1);
  position: relative;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.upload-zone-small {
  padding: 1.5rem 1rem;
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto .75rem;
  color: var(--text3);
}

.upload-icon svg { width: 100%; height: 100%; }

.upload-text {
  font-weight: 500;
  color: var(--text);
  margin-bottom: .3rem;
}

.upload-hint {
  color: var(--text2);
  font-size: .85rem;
  margin-bottom: .5rem;
}

.upload-formats {
  font-size: .78rem;
  color: var(--text3);
  display: block;
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ========= PHOTO PREVIEW GRID ========= */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: .75rem;
  margin-top: 1rem;
}

.preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg3);
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  background: rgba(0,0,0,.75);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .18s;
}

.preview-item:hover .preview-remove { opacity: 1; }

/* Always show remove on touch devices */
@media (hover: none) {
  .preview-remove { opacity: 1; }
}

.preview-item .overlay-num {
  position: absolute;
  bottom: 4px;
  left: 4px;
  font-size: .7rem;
  background: rgba(0,0,0,.65);
  color: #fff;
  padding: .15rem .4rem;
  border-radius: 4px;
}

/* ========= FIELDS ========= */
.field {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.label {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.label-optional {
  font-size: .75rem;
  color: var(--text3);
  font-weight: 400;
}

.input, .textarea, .select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  padding: .65rem .9rem;
  transition: border-color .18s, background .2s;
  outline: none;
  width: 100%;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
}

.textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

.select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='#5c6078' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  padding-right: 2.5rem;
}

.char-counter {
  font-size: .75rem;
  color: var(--text3);
  text-align: right;
}

.field-hint {
  font-size: .78rem;
  color: var(--text3);
  line-height: 1.4;
}

.field-hint .link {
  color: var(--accent);
  text-decoration: none;
}

.field-hint .link:hover { text-decoration: underline; }

/* ========= TOGGLE ========= */
.toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  cursor: pointer;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border2);
  border-radius: 99px;
  transition: .18s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text3);
  left: 3px;
  top: 3px;
  transition: .18s;
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: #fff; }

/* ========= PRICE FIELD ========= */
.price-input-wrap {
  display: flex;
  gap: .5rem;
}

.price-input-wrap .input { flex: 1; }
.currency-select { width: 100px !important; flex-shrink: 0; }

.hidden { display: none !important; }

/* ========= WATERMARK STATUS ========= */
.wm-status {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.wm-preview-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  background: repeating-conic-gradient(var(--wm-checker1) 0% 25%, var(--wm-checker2) 0% 50%) 0 0 / 12px 12px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wm-preview-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.wm-info { display: flex; flex-direction: column; gap: .2rem; }
.wm-name { font-size: .85rem; font-weight: 500; }
.wm-params { font-size: .75rem; color: var(--text3); }

.wm-empty {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text3);
  font-size: .85rem;
}

.wm-empty svg { width: 20px; height: 20px; }

/* ========= PUBLISH BUTTON ========= */
.btn-publish {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: .9rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .18s cubic-bezier(.4,0,.2,1);
  letter-spacing: -.01em;
}

.btn-publish:hover {
  background: var(--accent2);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(79,124,255,.35);
}

.btn-publish:active { transform: none; }
.btn-publish svg { width: 18px; height: 18px; }
.btn-publish.loading { opacity: .7; pointer-events: none; }

/* ========= SETTINGS PAGE ========= */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.settings-card { height: fit-content; }
.full-width { grid-column: 1 / -1; }

.card-title-group {
  display: flex;
  align-items: center;
  gap: .9rem;
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.card-icon svg { width: 18px; height: 18px; }

.tg-icon  { background: rgba(41,182,246,.15); color: #29b6f6; }
.wm-icon  { background: rgba(255,184,79,.12); color: var(--warn); }
.vis-icon { background: rgba(79,124,255,.15);  color: var(--accent); }

.card-desc {
  font-size: .8rem;
  color: var(--text3);
  margin-top: .15rem;
}

.field-row {
  display: flex;
  gap: .75rem;
  margin-top: 1.25rem;
}

.btn-primary {
  padding: .65rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .18s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  padding: .65rem 1.25rem;
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .18s;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ========= CURRENT WATERMARK ========= */
.current-watermark {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem;
  background: var(--bg3);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.wm-current-preview {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  background: repeating-conic-gradient(var(--wm-checker1) 0% 25%, var(--wm-checker2) 0% 50%) 0 0 / 14px 14px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wm-current-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.wm-current-info {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  flex: 1;
}

.wm-filename {
  font-size: .85rem;
  font-weight: 500;
  word-break: break-all;
}

.btn-danger-small {
  padding: .35rem .75rem;
  background: rgba(255,87,87,.1);
  color: var(--error);
  border: 1px solid rgba(255,87,87,.2);
  border-radius: 8px;
  font-size: .8rem;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all .18s;
  width: fit-content;
}

.btn-danger-small:hover { background: rgba(255,87,87,.2); }

/* ========= RANGE INPUTS ========= */
.range-input {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 4px;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: .72rem;
  color: var(--text3);
  margin-top: .2rem;
}

.range-value {
  background: var(--accent-glow);
  color: var(--accent);
  padding: .1rem .45rem;
  border-radius: 4px;
  font-size: .78rem;
  font-weight: 600;
  font-family: monospace;
}

/* ========= POSITION GRID ========= */
.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .4rem;
  max-width: 180px;
}

.pos-btn {
  aspect-ratio: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all .18s;
  user-select: none;
}

.pos-btn input { display: none; }
.pos-btn:hover { border-color: var(--accent); }
.pos-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* ========= LIVE WATERMARK PREVIEW ========= */
.wm-live-preview {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg3);
  border: 1px solid var(--border);
  aspect-ratio: 16/9;
}

.wm-preview-bg {
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(45deg, var(--preview-bg1) 25%, transparent 25%, transparent 75%, var(--preview-bg1) 75%),
    repeating-linear-gradient(45deg, var(--preview-bg1) 25%, var(--preview-bg2) 25%, var(--preview-bg2) 75%, var(--preview-bg1) 75%);
  background-size: 40px 40px;
  background-position: 0 0, 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wm-preview-bg span {
  font-size: .8rem;
  color: var(--text3);
  letter-spacing: .05em;
}

.wm-preview-overlay {
  position: absolute;
  pointer-events: none;
  transition: all .15s;
  max-width: 80%;
}

/* Settings params grid */
.settings-params-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 2rem;
  margin-bottom: 1.25rem;
}

/* ========= HISTORY ========= */
.history-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.history-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: border-color .18s;
}

.history-card:hover { border-color: var(--border2); }

.history-photos {
  display: flex;
  gap: .35rem;
  flex-shrink: 0;
}

.history-photo {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg3);
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}

.history-photo img { width: 100%; height: 100%; object-fit: cover; }

.photo-more-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
}

.history-info { flex: 1; min-width: 0; }

.history-meta {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .4rem;
  flex-wrap: wrap;
}

.history-date { font-size: .78rem; color: var(--text3); }

.history-price {
  font-size: .8rem;
  font-weight: 600;
  color: var(--success);
  background: rgba(34,201,122,.1);
  padding: .15rem .5rem;
  border-radius: 4px;
}

.history-status {
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 4px;
}

.status-sent  { background: rgba(34,201,122,.1); color: var(--success); }
.status-error { background: rgba(255,87,87,.1); color: var(--error); }

.history-desc {
  font-size: .85rem;
  color: var(--text2);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-actions {
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}

.btn-icon {
  width: 36px;
  height: 36px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .18s;
}

.btn-icon svg { width: 15px; height: 15px; }

.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon-danger:hover { border-color: var(--error); color: var(--error); }

/* ========= EMPTY STATE ========= */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text3);
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.25rem;
  color: var(--text3);
}

.empty-icon svg { width: 100%; height: 100%; }

.empty-state h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: .4rem;
}

.empty-state p { font-size: .9rem; color: var(--text3); }

/* ========= UPLOAD CARD ========= */
.upload-card { min-height: 300px; }

/* ========= LOADING SPINNER ========= */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========= MOBILE BOTTOM NAV ========= */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: .5rem .5rem calc(.5rem + env(safe-area-inset-bottom));
  z-index: 100;
  gap: .25rem;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: .5rem .25rem;
  border-radius: 10px;
  color: var(--text3);
  text-decoration: none;
  font-size: .68rem;
  font-weight: 500;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all .18s;
  min-height: 52px;
  justify-content: center;
}

.mobile-nav-item svg { width: 22px; height: 22px; }

.mobile-nav-item:hover,
.mobile-nav-item.active {
  color: var(--accent);
  background: var(--accent-glow);
}

.mobile-theme-btn { color: var(--text3); }
.mobile-theme-btn:hover { color: var(--accent); background: var(--accent-glow); }

/* ========= RESPONSIVE — TABLET ========= */
@media (max-width: 960px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 1.5rem 1.25rem;
  }

  .page-title { font-size: 1.5rem; }
}

/* ========= RESPONSIVE — MOBILE ========= */
@media (max-width: 640px) {
  /* Hide desktop sidebar, show mobile nav */
  .sidebar { display: none; }
  .mobile-nav { display: flex; }

  /* Offset content for bottom nav */
  .main-content {
    padding: 1rem 1rem 5.5rem;
    max-width: 100%;
  }

  /* Compact header */
  .page-header { margin-bottom: 1.25rem; }
  .page-title  { font-size: 1.35rem; }
  .page-subtitle { font-size: .82rem; }

  /* Cards */
  .card { padding: 1.1rem; }
  .card-header { margin-bottom: 1rem; }

  /* Upload zone smaller on mobile */
  .upload-zone { padding: 1.75rem 1rem; }
  .upload-icon { width: 36px; height: 36px; }

  /* Preview grid — bigger thumbs on mobile */
  .preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: .5rem;
  }

  /* Side cards go full width (already stacked via form-grid) */
  .side-cards { gap: 1rem; }

  /* Textarea shorter */
  .textarea { rows: 4; min-height: 80px; }

  /* Price wrap stacks on very small */
  .price-input-wrap { flex-direction: column; }
  .currency-select { width: 100% !important; }

  /* Settings grid single col */
  .settings-params-grid { grid-template-columns: 1fr; }

  /* History cards compact */
  .history-card {
    padding: .85rem 1rem;
    flex-wrap: wrap;
    gap: .75rem;
  }
  .history-photos { flex-wrap: wrap; }
  .history-photo { width: 48px; height: 48px; }
  .history-actions { margin-left: auto; }

  /* Empty state */
  .empty-state { padding: 2.5rem 1rem; }

  /* Alerts */
  .alert { font-size: .85rem; padding: .75rem .9rem; }

  /* Buttons full width in field-row */
  .field-row { flex-direction: column; }
  .field-row .btn-primary,
  .field-row .btn-secondary { width: 100%; justify-content: center; }

  /* Theme toggle header — hide on mobile (use bottom nav) */
  .theme-toggle-header { display: none; }

  /* Watermark live preview */
  .wm-live-preview { aspect-ratio: 4/3; }
}

/* ========= RESPONSIVE — VERY SMALL ========= */
@media (max-width: 380px) {
  .preview-grid { grid-template-columns: repeat(3, 1fr); }
  .page-title { font-size: 1.2rem; }
}n-items: center;
}

.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  padding: .65rem 1.25rem;
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ========= CURRENT WATERMARK ========= */
.current-watermark {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.wm-current-preview {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: repeating-conic-gradient(#2a2d35 0% 25%, transparent 0% 50%) 0 0 / 14px 14px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wm-current-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.wm-current-info {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  flex: 1;
}

.wm-filename {
  font-size: .85rem;
  font-weight: 500;
  word-break: break-all;
}

.btn-danger-small {
  padding: .35rem .75rem;
  background: rgba(255,87,87,.1);
  color: var(--error);
  border: 1px solid rgba(255,87,87,.2);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition);
  width: fit-content;
}

.btn-danger-small:hover { background: rgba(255,87,87,.2); }

/* ========= RANGE INPUTS ========= */
.range-input {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 4px;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: .72rem;
  color: var(--text3);
  margin-top: .2rem;
}

.range-value {
  background: var(--accent-glow);
  color: var(--accent);
  padding: .1rem .45rem;
  border-radius: 4px;
  font-size: .78rem;
  font-weight: 600;
  font-family: monospace;
}

/* ========= POSITION GRID ========= */
.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .4rem;
  max-width: 180px;
}

.pos-btn {
  aspect-ratio: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--transition);
  user-select: none;
}

.pos-btn input { display: none; }

.pos-btn:hover { border-color: var(--accent); }
.pos-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* ========= LIVE WATERMARK PREVIEW ========= */
.wm-live-preview {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg3);
  border: 1px solid var(--border);
  aspect-ratio: 16/9;
}

.wm-preview-bg {
  width: 100%;
  height: 100%;
  background: 
    repeating-linear-gradient(45deg, #1b1d22 25%, transparent 25%, transparent 75%, #1b1d22 75%),
    repeating-linear-gradient(45deg, #1b1d22 25%, #141518 25%, #141518 75%, #1b1d22 75%);
  background-size: 40px 40px;
  background-position: 0 0, 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wm-preview-bg span {
  font-size: .8rem;
  color: var(--text3);
  letter-spacing: .05em;
}

.wm-preview-overlay {
  position: absolute;
  pointer-events: none;
  transition: all .15s;
  max-width: 80%;
}

/* Settings params grid */
.settings-params-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 2rem;
  margin-bottom: 1.25rem;
}

/* ========= HISTORY ========= */
.history-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.history-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: border-color var(--transition);
}

.history-card:hover { border-color: var(--border2); }

.history-photos {
  display: flex;
  gap: .35rem;
  flex-shrink: 0;
}

.history-photo {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg3);
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}

.history-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-more-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
}

.history-info {
  flex: 1;
  min-width: 0;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .4rem;
  flex-wrap: wrap;
}

.history-date {
  font-size: .78rem;
  color: var(--text3);
}

.history-price {
  font-size: .8rem;
  font-weight: 600;
  color: var(--success);
  background: rgba(34,201,122,.1);
  padding: .15rem .5rem;
  border-radius: 4px;
}

.history-status {
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 4px;
}

.status-sent  { background: rgba(34,201,122,.1); color: var(--success); }
.status-error { background: rgba(255,87,87,.1); color: var(--error); }

.history-desc {
  font-size: .85rem;
  color: var(--text2);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-actions {
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}

.btn-icon {
  width: 36px;
  height: 36px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition);
}

.btn-icon svg { width: 15px; height: 15px; }

.btn-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-icon-danger:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ========= EMPTY STATE ========= */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text3);
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.25rem;
  color: var(--text3);
}

.empty-icon svg {
  width: 100%;
  height: 100%;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: .4rem;
}

.empty-state p {
  font-size: .9rem;
  color: var(--text3);
}

/* ========= UPLOAD CARD ========= */
.upload-card {
  min-height: 300px;
}

/* ========= LOADING SPINNER ========= */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========= RESPONSIVE ========= */
@media (max-width: 900px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .main-content {
    padding: 1.5rem 1.25rem;
  }
}

@media (max-width: 640px) {
  .sidebar { width: 60px; }
  .logo-text, .nav-item a span, .sidebar-status span { display: none; }
  .nav-item a { justify-content: center; padding: .6rem; }
  .nav-item a svg { opacity: 1; }
  .sidebar-logo { justify-content: center; padding: 0; }
  .logo-text { display: none; }
  .sidebar-status { justify-content: center; }
  .settings-params-grid { grid-template-columns: 1fr; }
}

/* ========= PHOTO DRAG REORDER ========= */
.preview-item { cursor: grab; }
.preview-item:active { cursor: grabbing; }
.preview-item.dragging {
  opacity: .4;
  transform: scale(.96);
  border-style: dashed;
  border-color: var(--accent);
}
.preview-item.drag-over-item {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.04);
}
.preview-item.touch-dragging {
  opacity: .5;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.drag-handle {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  background: rgba(0,0,0,.65);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  transition: opacity .18s;
  cursor: grab;
}
.preview-item:hover .drag-handle { opacity: 1; }
@media (hover: none) {
  .drag-handle { opacity: 1; }
}

/* ========= MOBILE PUBLISH BUTTON FIX ========= */
/* On mobile the .side-cards (with publish btn) go below upload card.
   Ensure publish button is always visible above bottom nav */
@media (max-width: 640px) {
  .btn-publish {
    position: sticky;
    bottom: calc(4.5rem + env(safe-area-inset-bottom));
    z-index: 50;
    box-shadow: 0 -4px 20px rgba(0,0,0,.35), 0 8px 24px rgba(79,124,255,.3);
  }
}

/* Watermark save indicator */
#wmSaveIndicator {
  font-size: .78rem;
  font-weight: 500;
  transition: color .2s;
  min-width: 90px;
  text-align: right;
}