/* Фото с комментариями — современные стили, пропорции популярных экранов */
:root {
  --bg: #0f0f14;
  --surface: #1a1b2e;
  --surface2: #252640;
  --text: #e8e8ed;
  --text-muted: #9090a0;
  --accent: #7c9cff;
  --accent-hover: #9ab2ff;
  --danger: #e85d7a;
  --success: #5dd9a3;
  --radius: 12px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --header-h: 52px;
  /* Пропорции: iPhone 14 390x844, iPhone SE 375x667, Android 360x800, 412x915 */
  --max-width: 480px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--safe-top) 0 var(--safe-bottom);
}

/* Login */
.page-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card h1 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 1.5rem;
}

.login-card .form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card input {
  font-size: 1.25rem;
  letter-spacing: 0.1em;
  text-align: center;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 12px;
}

.hidden {
  display: none !important;
}

/* App layout */
.page-app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-bottom: 20px;
}

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 16px;
  padding-top: var(--safe-top);
  background: var(--surface);
  border-bottom: 1px solid var(--surface2);
}

.user-id {
  font-weight: 600;
  font-size: 0.95rem;
}

.admin-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.admin-link:hover {
  text-decoration: underline;
}

.tabs {
  display: flex;
  gap: 0;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--surface2);
}

.tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.panel {
  display: none;
  padding: 16px;
  animation: fade 0.2s ease;
}

.panel.active {
  display: block;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--surface2);
}

.card h2 {
  font-size: 1.1rem;
  margin: 0 0 12px;
  font-weight: 600;
}

.hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.hint code {
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* Forms */
.form label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form input[type="text"],
.form input[type="number"],
.form textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--surface2);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.form input:focus,
.form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 156, 255, 0.2);
}

.form textarea {
  resize: vertical;
  min-height: 60px;
}

.tz-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tz-row label {
  margin-bottom: 0;
}

.tz-row input[type="number"] {
  width: 64px;
  margin-bottom: 0;
}

.process-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.hint.small {
  font-size: 0.85rem;
  margin-bottom: 12px;
}

/* Buttons */
button,
.btn-primary,
.btn-secondary,
.btn-ghost {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
}

.btn-secondary:hover {
  background: #32355a;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
}

.btn-ghost:hover {
  background: var(--surface2);
}

.file-label {
  cursor: pointer;
  display: inline-block;
}

.add-comment .add-actions,
.add-product .add-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.add-comment .or,
.add-product .or {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  min-width: 0;
}

.list-header h2 {
  margin: 0;
}

.list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.list-actions .btn-ghost,
.list-actions .file-label {
  white-space: nowrap;
}

.comments-list,
.products-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.comments-list li,
.products-list li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--surface2);
}

.comments-list li:last-child,
.products-list li:last-child {
  border-bottom: none;
}

.comment-body,
.product-body {
  flex: 1;
  min-width: 0;
}

.comment-time,
.product-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.comment-text,
.product-value {
  word-break: break-word;
}

.comment-delete,
.product-delete {
  flex-shrink: 0;
  padding: 6px 10px;
  font-size: 0.85rem;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.comment-delete:hover,
.product-delete:hover {
  background: var(--danger);
  color: #fff;
}

.result-msg {
  margin-top: 12px;
  font-size: 0.9rem;
}

.result-msg.success {
  color: var(--success);
}

.result-msg.error {
  color: var(--danger);
}

/* Admin */
.allowed-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.allowed-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--surface2);
}

.allowed-list .aid {
  font-family: monospace;
  font-weight: 600;
  min-width: 100px;
}

.allowed-list .aname {
  flex: 1;
  color: var(--text-muted);
}

.allowed-list .remove-allowed {
  padding: 4px 10px;
  font-size: 0.85rem;
  color: var(--danger);
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: 6px;
  cursor: pointer;
}

.add-allowed {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.add-allowed input[type="text"]:first-of-type {
  width: 110px;
}

.add-allowed input:nth-of-type(2) {
  flex: 1;
  min-width: 100px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.generated-id {
  font-family: monospace;
  font-size: 1.1rem;
  color: var(--accent);
}

/* Safe areas for notched phones */
@media (max-width: 430px) {
  .add-comment .add-actions,
  .add-product .add-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (min-width: 500px) {
  .page-app {
    padding-left: 20px;
    padding-right: 20px;
  }
}
