/* ============================================================
   FORGEPOST — Telegram Dark Theme
   ============================================================ */

:root {
  --bg:        #212121;
  --bg2:       #2b2b2b;
  --bg3:       #333333;
  --bg4:       #3a3a3a;
  --border:    #3a3a3a;
  --border2:   #444444;
  --accent:    #2eaadc;
  --accent-dim:#1a7fa8;
  --accent-bg: rgba(46,170,220,0.1);
  --text:      #f5f5f5;
  --text2:     #aaaaaa;
  --text3:     #666666;
  --red:       #e05555;
  --green:     #4dca6e;
  --yellow:    #e0a84d;
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --radius:    8px;
  --radius2:   12px;
  --sidebar-w: 240px;
  --shadow:    0 2px 12px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}

.login-bg { display: none; }

.login-card {
  width: 380px;
  background: var(--bg2);
  border-radius: var(--radius2);
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 6px;
}

.login-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.login-subtitle {
  color: var(--text2);
  font-size: 13px;
  margin-bottom: 28px;
}

.login-logo svg polygon, .login-logo svg path { stroke: var(--accent); }
.login-error {
  background: rgba(224,85,85,0.12);
  border: 1px solid rgba(224,85,85,0.3);
  color: #e08080;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
}
.login-hint { display: none; }

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 13px; color: var(--text2);
  margin-bottom: 6px; font-weight: 400;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="time"], input[type="number"],
textarea, select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46,170,220,0.15);
}

input[readonly] {
  background: var(--bg3);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 13px;
}

textarea { resize: vertical; }

select {
  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='%23aaaaaa' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

input[type="range"] {
  -webkit-appearance: none;
  background: var(--bg4);
  border: none; height: 4px; border-radius: 2px; padding: 0; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; background: var(--accent); border-radius: 50%; cursor: pointer;
}

.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); font-family: var(--font);
  font-size: 14px; font-weight: 500; padding: 9px 18px;
  cursor: pointer; transition: background 0.15s; white-space: nowrap;
}
.btn-primary:hover { background: #3dbce8; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--bg3); color: var(--text2);
  border: 1px solid var(--border2); border-radius: var(--radius);
  font-family: var(--font); font-size: 14px; font-weight: 400;
  padding: 9px 18px; cursor: pointer;
  transition: background 0.15s, color 0.15s; white-space: nowrap;
}
.btn-secondary:hover { background: var(--bg4); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-regen {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border2); color: var(--text2);
  border-radius: var(--radius); font-family: var(--font);
  font-size: 13px; padding: 9px; cursor: pointer; margin-bottom: 18px;
  transition: background 0.15s, color 0.15s;
}
.btn-regen:hover { background: var(--bg4); color: var(--accent); }

.btn-copy {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: var(--bg4); border: 1px solid var(--border2);
  color: var(--text3); border-radius: 6px; padding: 4px 6px;
  cursor: pointer; transition: color 0.15s; line-height: 0;
}
.btn-copy.top { top: 8px; transform: none; }
.btn-copy:hover { color: var(--accent); }

.btn-remove {
  background: rgba(224,85,85,0.15); color: var(--red); border: none;
  border-radius: 6px; width: 28px; height: 28px; cursor: pointer;
  font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.btn-remove:hover { background: rgba(224,85,85,0.3); }

.btn-remove-sm {
  background: none; border: none; color: var(--text3);
  cursor: pointer; font-size: 14px; padding: 2px 6px; margin-left: auto;
}
.btn-remove-sm:hover { color: var(--red); }

.input-copy-wrap { position: relative; }
.input-copy-wrap input, .input-copy-wrap textarea { padding-right: 44px; }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); min-height: 100vh;
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 600; color: var(--text);
}
.sidebar-logo svg polygon, .sidebar-logo svg path { stroke: var(--accent); }

.sidebar-nav {
  flex: 1; padding: 10px 8px;
  display: flex; flex-direction: column; gap: 2px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius);
  color: var(--text2); cursor: pointer; text-decoration: none;
  font-size: 14px; transition: background 0.1s, color 0.1s;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); }

.sidebar-user {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; transition: background 0.1s;
}
.sidebar-user:hover { background: var(--bg3); }

.user-avatar {
  width: 32px; height: 32px; background: var(--accent); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-info span:first-child {
  font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-logout { font-size: 12px; color: var(--text3); }

.content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }

.tab-content { display: none; padding: 28px 32px; }
.tab-content.active { display: block; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--border);
}
.page-header h1 { font-size: 20px; font-weight: 600; color: var(--text); }
.page-subtitle { color: var(--text2); font-size: 13px; margin-top: 2px; }
.header-filters, .header-actions { display: flex; align-items: center; gap: 8px; }
.header-filters select { width: 160px; }

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 500;
  background: var(--bg4); border: 1px solid var(--border2); color: var(--text2);
}
.badge-auto { border-color: var(--accent-dim); color: var(--accent); background: var(--accent-bg); }
.badge-file { border-color: #5588cc; color: #88aaee; background: rgba(85,136,204,0.1); }

.history-table-wrap {
  overflow-x: auto; border: 1px solid var(--border);
  border-radius: var(--radius2); background: var(--bg2);
}

.history-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.history-table thead { background: var(--bg3); }
.history-table th {
  padding: 11px 16px; text-align: left;
  font-size: 12px; font-weight: 500; color: var(--text2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.history-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.history-table tbody tr:last-child td { border-bottom: none; }
.history-table tbody tr { cursor: pointer; transition: background 0.1s; }
.history-table tbody tr:hover { background: var(--bg3); }

.post-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border2); }
.post-thumb-placeholder {
  width: 48px; height: 48px; background: var(--bg3); border-radius: 6px;
  border: 1px solid var(--border2); display: flex; align-items: center;
  justify-content: center; color: var(--text3); font-size: 18px;
}
.post-code { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.post-name { color: var(--text); }

.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }
.status-draft     { background: rgba(100,100,100,0.2); color: #888; border: 1px solid #555; }
.status-queued    { background: rgba(46,170,220,0.15); color: var(--accent); border: 1px solid rgba(46,170,220,0.4); }
.status-published { background: rgba(77,202,110,0.15); color: var(--green); border: 1px solid rgba(77,202,110,0.4); }
.post-date { font-size: 13px; color: var(--text2); }

.btn-detail {
  background: none; border: 1px solid var(--border2); color: var(--text2);
  padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
  transition: border-color 0.15s, color 0.15s;
}
.btn-detail:hover { border-color: var(--accent); color: var(--accent); }

.post-form { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.form-section { margin-bottom: 22px; }
.section-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.upload-zone {
  border: 1px dashed var(--border2); border-radius: var(--radius);
  background: var(--bg2); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative; overflow: hidden;
}
.upload-zone:hover { border-color: var(--accent); background: var(--bg3); }
.upload-zone-sm   { min-height: 72px; }
.upload-zone-file { min-height: 56px; }

.upload-placeholder {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; padding: 24px 16px;
  color: var(--text3); text-align: center;
}
.upload-placeholder span  { font-size: 13px; color: var(--text2); }
.upload-placeholder small { font-size: 12px; color: var(--text3); }
.upload-zone-sm   .upload-placeholder { padding: 14px; flex-direction: row; gap: 8px; }
.upload-zone-file .upload-placeholder { padding: 12px 16px; flex-direction: row; gap: 8px; }

.upload-preview { position: relative; }
.upload-preview img { width: 100%; max-height: 200px; object-fit: cover; display: block; }
.preview-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.5);
  opacity: 0; transition: opacity 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.upload-preview:hover .preview-overlay { opacity: 1; }

.btn-wm-cover {
  display: flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); padding: 8px 14px;
  font-size: 13px; font-weight: 500; cursor: pointer;
}

.extras-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.extra-item { position: relative; border-radius: 6px; overflow: hidden; border: 1px solid var(--border2); }
.extra-item img { width: 100%; height: 72px; object-fit: cover; display: block; }
.wm-badge {
  position: absolute; top: 4px; left: 4px;
  background: rgba(46,170,220,0.85); color: #fff;
  font-size: 9px; font-weight: 600; padding: 1px 5px;
  border-radius: 3px; font-family: var(--font-mono);
}
.extra-remove {
  position: absolute; top: 4px; right: 4px;
  background: rgba(224,85,85,0.85); color: white; border: none;
  border-radius: 3px; width: 20px; height: 20px;
  cursor: pointer; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.stl-preview { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 13px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius2); padding: 20px; }
.settings-card h3 {
  font-size: 14px; font-weight: 600; color: var(--text);
  margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.settings-card-full { grid-column: 1 / -1; }
.card-hint { color: var(--text2); font-size: 13px; margin-bottom: 14px; }

.randomizer-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.rand-column h4 {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text2); margin-bottom: 8px;
}
.rand-items { display: flex; flex-direction: column; gap: 3px; }
.rand-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 8px; font-size: 12px; color: var(--text2);
}
.rand-item-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex-shrink: 0; opacity: 0.6; }
.rand-item .rand-delete {
  margin-left: auto; background: none; border: none; color: var(--text3);
  cursor: pointer; font-size: 11px; padding: 0 2px; opacity: 0; transition: opacity 0.1s, color 0.1s;
}
.rand-item:hover .rand-delete { opacity: 1; }
.rand-item:hover .rand-delete:hover { color: var(--red); }
.btn-rand-add {
  display: block; width: 100%; margin-top: 6px; background: none;
  border: 1px dashed var(--border2); color: var(--text3); border-radius: 6px;
  padding: 5px; cursor: pointer; font-size: 12px; transition: border-color 0.15s, color 0.15s;
}
.btn-rand-add:hover { border-color: var(--accent); color: var(--accent); }

.combo-history-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 280px; overflow-y: auto; padding-right: 4px;
}
.combo-history-item {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 12px; font-family: var(--font-mono); font-size: 12px; color: var(--text2);
  display: flex; align-items: center; gap: 10px;
}
.combo-count { color: var(--accent); flex-shrink: 0; font-size: 11px; }
.combo-date  { color: var(--text3); font-size: 11px; flex-shrink: 0; }

.wm-preview-wrap {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px; padding: 16px;
}

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; opacity: 0; pointer-events: none;
  transition: opacity 0.15s; backdrop-filter: blur(2px);
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal-box {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius2); padding: 28px; position: relative;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}
.modal-lg { width: 640px; max-width: 95vw; }
.modal-xl { width: 860px; max-width: 95vw; }
.modal-close {
  position: absolute; top: 14px; right: 14px; background: var(--bg3);
  border: 1px solid var(--border2); color: var(--text2);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  font-size: 13px; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg4); color: var(--text); }
.modal-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 18px; }

.post-detail-header { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.post-detail-cover { width: 110px; height: 110px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border2); flex-shrink: 0; }
.post-detail-meta h2 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.meta-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 13px; color: var(--text2); }
.meta-label { font-size: 12px; color: var(--text3); min-width: 90px; }
.post-detail-section { margin-bottom: 18px; }
.post-detail-section h4 {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text3); margin-bottom: 8px;
}
.post-text-block {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  font-family: var(--font-mono); font-size: 13px;
  white-space: pre-wrap; color: var(--text); line-height: 1.6;
}

.wm-editor { display: grid; grid-template-columns: 1fr 200px; gap: 18px; align-items: start; }
.wm-canvas-wrap {
  position: relative; background: var(--bg4); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; min-height: 280px;
  display: flex; align-items: center; justify-content: center;
}
#wmCanvas { max-width: 100%; display: block; }
.wm-handle { position: absolute; border: 2px dashed var(--accent); border-radius: 2px; cursor: move; }
.wm-controls { display: flex; flex-direction: column; gap: 14px; }
.wm-hint {
  font-size: 12px; color: var(--text2); padding: 10px;
  background: var(--bg3); border-radius: var(--radius);
  border: 1px solid var(--border); text-align: center;
}
.wm-editor-actions { display: flex; gap: 8px; }

.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 10px 16px;
  font-size: 13px; color: var(--text); z-index: 2000;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none; box-shadow: var(--shadow);
}
.toast.show    { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

.empty-state { text-align: center; padding: 52px 20px; color: var(--text3); }
.empty-state svg { opacity: 0.3; margin-bottom: 10px; display: block; margin-left: auto; margin-right: auto; }
.empty-state p   { font-size: 14px; color: var(--text2); margin-bottom: 4px; }
.empty-state small { font-size: 13px; color: var(--text3); }
