  :root {
    --bg: #fbfaf7;
    --card: #ffffff;
    --border: #ececec;
    --text: #1a1a1a;
    --text-soft: #6b6b6b;
    --text-muted: #9a9a9a;
    --accent: #c73e1d;
    --accent-hover: #a83319;
    --accent-soft: #fce9e4;
    --saved: #1a1a1a;
    --danger: #d33d3d;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.14);
    --radius: 14px;
    --radius-sm: 8px;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; }
  body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
  }
  a { color: inherit; text-decoration: none; cursor: pointer; }
  button { font-family: inherit; cursor: pointer; }

  /* ============ HEADER ============ */
  .header {
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 40;
    border-bottom: 1px solid var(--border);
  }
  .header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
  }
  .logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.02em;
    color: var(--text);
    flex-shrink: 0;
  }
  .logo-mark {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 16px;
  }
  .logo-tld {
    color: var(--accent);
    font-weight: 800;
  }
  .logo-spacer { flex: 1; }

  /* active tag filter chip */
  .filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
  }
  .filter-bar-label {
    font-size: 13px;
    color: var(--text-soft);
  }
  .filter-bar-tag {
    font-weight: 700;
    color: var(--accent);
    font-size: 14px;
  }
  .filter-bar-clear {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-soft);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .filter-bar-clear:hover { background: rgba(0,0,0,0.06); color: var(--text); }

  /* comment count on card */
  .pin-comment-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
  }
  .pin:hover .pin-comment-badge { opacity: 1; }
  @media (hover: none) {
    .pin-comment-badge { opacity: 1; }
  }

  /* comments in detail modal */
  .comments-section {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 16px;
  }
  .comments-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
  }
  .comments-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
  }
  .comment {
    display: flex;
    gap: 10px;
  }
  .comment-body { flex: 1; min-width: 0; }
  .comment-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
  }
  .comment-author {
    font-weight: 700;
    font-size: 13px;
  }
  .comment-time {
    font-size: 11px;
    color: var(--text-muted);
  }
  .comment-text {
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
    word-wrap: break-word;
    white-space: pre-wrap;
  }
  .comment-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    padding: 0;
    margin-top: 2px;
    cursor: pointer;
  }
  .comment-delete:hover { color: var(--danger); }
  .comments-empty {
    text-align: center;
    padding: 16px 0;
    color: var(--text-muted);
    font-size: 13px;
  }
  .comment-form {
    display: flex;
    gap: 8px;
    align-items: flex-start;
  }
  .comment-form textarea {
    flex: 1;
    padding: 9px 12px;
    background: white;
    border: 1px solid #dcdcdc;
    border-radius: 18px;
    font-family: inherit;
    font-size: 13px;
    resize: none;
    min-height: 38px;
    max-height: 100px;
    line-height: 1.4;
    color: var(--text);
  }
  .comment-form textarea:focus {
    outline: none;
    border-color: var(--text);
  }
  .comment-form button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 9px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
  }
  .comment-form button:hover { background: var(--accent-hover); }
  .comment-form button:disabled { background: var(--text-muted); cursor: not-allowed; }
  .comment-login-hint {
    text-align: center;
    padding: 12px;
    background: #fafaf7;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-soft);
  }
  .comment-login-hint a { color: var(--accent); font-weight: 700; cursor: pointer; }

  /* footer */
  .footer {
    max-width: 1600px;
    margin: 40px auto 0;
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 10px;
  }
  .footer-brand {
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.01em;
  }
  .footer-brand .accent { color: var(--accent); }

  /* config not-set banner */
  .config-banner {
    position: fixed;
    inset: 0;
    background: #1a1a1a;
    color: white;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    font-family: 'Inter', sans-serif;
  }
  .config-banner-inner {
    max-width: 560px;
    text-align: left;
  }
  .config-banner h1 {
    font-size: 22px;
    margin-bottom: 12px;
    font-weight: 800;
  }
  .config-banner h1 span { color: #c73e1d; }
  .config-banner p {
    color: #bbb;
    line-height: 1.55;
    margin-bottom: 12px;
    font-size: 14px;
  }
  .config-banner code {
    background: #333;
    color: #eee;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
  }
  .config-banner pre {
    background: #000;
    color: #eee;
    padding: 14px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    overflow-x: auto;
    margin: 12px 0;
    line-height: 1.5;
  }
  .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }
  .lang {
    display: flex;
    background: #efece7;
    border-radius: 999px;
    padding: 2px;
  }
  .lang button {
    background: none;
    border: none;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-soft);
    border-radius: 999px;
  }
  .lang button.active { background: white; color: var(--text); box-shadow: var(--shadow-sm); }

  .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
  }
  .icon-btn:hover { background: #efece7; color: var(--text); }

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    transition: background 0.12s, transform 0.05s;
  }
  .btn:active { transform: scale(0.97); }
  .btn-primary { background: var(--accent); color: white; }
  .btn-primary:hover { background: var(--accent-hover); }
  .btn-dark { background: var(--text); color: white; }
  .btn-dark:hover { background: #333; }
  .btn-light { background: #efece7; color: var(--text); }
  .btn-light:hover { background: #e5e2dc; }
  .btn-ghost { background: transparent; color: var(--text-soft); }
  .btn-ghost:hover { background: #efece7; color: var(--text); }
  .btn-sm { padding: 6px 12px; font-size: 13px; }
  .btn:disabled { opacity: 0.5; cursor: not-allowed; }

  .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
  }
  .avatar-lg { width: 44px; height: 44px; font-size: 16px; }
  .avatar-xl { width: 96px; height: 96px; font-size: 36px; }

  /* user menu */
  .user-menu { position: relative; }
  .user-menu-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    padding: 4px;
    display: none;
    z-index: 50;
  }
  .user-menu-panel.open { display: block; }
  .user-menu-item {
    display: block;
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
  }
  .user-menu-item:hover { background: #efece7; }
  .user-menu-info { padding: 12px 14px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
  .user-menu-name { font-weight: 700; font-size: 14px; }
  .user-menu-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

  @media (max-width: 640px) {
    .header-inner { gap: 8px; padding: 10px 12px; }
    .logo span { display: none; }
    .lang { display: none; }
    .btn { padding: 8px 12px; font-size: 13px; }
    .btn .btn-text { display: none; }
    .btn-primary { padding: 8px 12px; }
  }

  /* ============ MAIN ============ */
  .main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px 20px 80px;
  }

  .tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-soft);
    white-space: nowrap;
  }
  .tab:hover { background: #efece7; color: var(--text); }
  .tab.active { background: var(--text); color: white; border-color: var(--text); }

  /* ============ MASONRY GRID ============ */
  .masonry {
    column-count: 2;
    column-gap: 14px;
  }
  @media (min-width: 520px) { .masonry { column-count: 3; } }
  @media (min-width: 800px) { .masonry { column-count: 4; column-gap: 16px; } }
  @media (min-width: 1200px) { .masonry { column-count: 5; column-gap: 16px; } }
  @media (min-width: 1500px) { .masonry { column-count: 6; column-gap: 16px; } }

  .pin {
    break-inside: avoid;
    margin-bottom: 14px;
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: zoom-in;
    background: #f0eee8;
    transition: transform 0.15s;
  }
  @media (min-width: 800px) { .pin { margin-bottom: 16px; } }
  .pin:hover { transform: translateY(-2px); }
  .pin img {
    width: 100%;
    display: block;
    height: auto;
  }
  .pin-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0) 60%, rgba(0,0,0,0.5) 100%);
    opacity: 0;
    transition: opacity 0.15s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px;
    pointer-events: none;
  }
  .pin:hover .pin-overlay { opacity: 1; }
  .pin-save-btn {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    border: none;
    pointer-events: auto;
  }
  .pin-save-btn:hover { background: var(--accent-hover); }
  .pin-save-btn.saved {
    background: var(--saved);
  }
  .pin-caption-preview {
    color: white;
    font-size: 12px;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    max-height: 40px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  /* touch devices - always show subtle save button */
  @media (hover: none) {
    .pin-overlay { opacity: 1; background: linear-gradient(to bottom, rgba(0,0,0,0) 70%, rgba(0,0,0,0.3) 100%); }
    .pin-save-btn { padding: 6px 12px; font-size: 12px; }
  }

  .pin-footer {
    padding: 8px 4px 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-soft);
  }
  .pin-footer .avatar { width: 20px; height: 20px; font-size: 10px; }

  /* empty */
  .empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
  }
  .empty-title { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
  .empty-sub { font-size: 14px; }

  .loading {
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
    font-size: 13px;
  }

  /* ============ MODAL ============ */
  .modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
  }
  .modal-bg.open { display: flex; }

  /* ---- Pin detail ---- */
  .pin-modal {
    background: white;
    border-radius: 20px;
    max-width: 950px;
    width: 100%;
    max-height: 92vh;
    display: flex;
    overflow: hidden;
    position: relative;
  }
  .pin-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
  }
  .pin-modal-close:hover { background: #efece7; }
  .pin-modal-img {
    width: 55%;
    background: #f0eee8;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 92vh;
  }
  .pin-modal-img img {
    max-width: 100%;
    max-height: 92vh;
    display: block;
    object-fit: contain;
  }
  .pin-modal-side {
    width: 45%;
    padding: 28px 24px 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  .pin-modal-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
  }
  .pin-modal-caption {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 12px;
    color: var(--text);
    word-wrap: break-word;
  }
  .pin-modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
  }
  .tag-chip {
    padding: 4px 10px;
    background: #efece7;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-soft);
    cursor: pointer;
  }
  .tag-chip:hover { background: #e5e2dc; color: var(--text); }
  .pin-modal-author {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    margin-top: auto;
  }
  .pin-modal-author-info { flex: 1; min-width: 0; }
  .pin-modal-author-name { font-weight: 600; font-size: 14px; }
  .pin-modal-author-meta { font-size: 12px; color: var(--text-muted); }
  .pin-modal-stats {
    display: flex;
    gap: 14px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-soft);
  }
  .pin-modal-stats strong { color: var(--text); font-weight: 700; }

  @media (max-width: 820px) {
    .pin-modal { flex-direction: column; max-height: 95vh; }
    .pin-modal-img { width: 100%; max-height: 60vh; }
    .pin-modal-side { width: 100%; padding: 20px; }
    .pin-modal-author { margin-top: 16px; }
  }

  /* ---- Upload / Auth modal ---- */
  .modal {
    background: white;
    border-radius: 20px;
    max-width: 460px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    padding: 28px;
    position: relative;
  }
  .modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-soft);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .modal-close:hover { background: #efece7; color: var(--text); }
  .modal-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 6px;
    text-align: center;
    letter-spacing: -0.01em;
  }
  .modal-sub {
    text-align: center;
    color: var(--text-soft);
    font-size: 13px;
    margin-bottom: 22px;
  }

  .form-field { margin-bottom: 14px; }
  .form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 5px;
  }
  .form-input, .form-textarea {
    width: 100%;
    padding: 11px 14px;
    background: white;
    border: 1px solid #dcdcdc;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    transition: border-color 0.1s, box-shadow 0.1s;
  }
  .form-input:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--text);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
  }
  .form-textarea { resize: vertical; min-height: 70px; line-height: 1.4; font-family: inherit; }
  .form-help { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
  .form-error {
    font-size: 13px;
    color: var(--danger);
    background: #fbe8e8;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
  }

  .drop-zone {
    border: 2px dashed #d0d0d0;
    border-radius: var(--radius-sm);
    padding: 32px 20px;
    text-align: center;
    background: #fafaf7;
    cursor: pointer;
    display: block;
    transition: all 0.15s;
  }
  .drop-zone:hover, .drop-zone.dragging {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
  .drop-zone-icon { color: var(--text-muted); margin-bottom: 10px; }
  .drop-zone-title { font-weight: 600; font-size: 15px; color: var(--text); margin-bottom: 4px; }
  .drop-zone-sub { font-size: 12px; color: var(--text-muted); }
  .drop-zone input { display: none; }

  .drop-preview {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #f0eee8;
  }
  .drop-preview img { width: 100%; max-height: 340px; object-fit: contain; display: block; }
  .drop-preview-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .modal-submit {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 15px;
    margin-top: 8px;
  }
  .modal-footer-link {
    text-align: center;
    font-size: 13px;
    color: var(--text-soft);
    margin-top: 16px;
  }
  .modal-footer-link a { color: var(--accent); font-weight: 600; }
  .modal-footer-link a:hover { text-decoration: underline; }

  /* profile view */
  .profile-header {
    text-align: center;
    padding: 30px 20px;
    margin-bottom: 20px;
  }
  .profile-name {
    font-size: 26px;
    font-weight: 800;
    margin-top: 14px;
    letter-spacing: -0.01em;
  }
  .profile-meta {
    color: var(--text-soft);
    font-size: 13px;
    margin-top: 4px;
  }
  .profile-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-soft);
  }
  .profile-stats strong { color: var(--text); font-weight: 700; }

  /* toast */
  .toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: white;
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.2s;
    pointer-events: none;
    z-index: 300;
    box-shadow: var(--shadow-md);
    max-width: 90vw;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* delete button on own pin */
  .pin-delete {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: auto;
  }
  .pin:hover .pin-delete { opacity: 1; }
  .pin-delete:hover { background: var(--danger); }

  .icon { width: 20px; height: 20px; stroke-width: 2; fill: none; stroke: currentColor; }
  .icon-sm { width: 16px; height: 16px; }
