:root {
    --bg: #fafaf9;
    --card: #ffffff;
    --border: #e7e5e4;
    --text: #1c1917;
    --muted: #78716b;
    --accent: #1c1917;
    --primary: #7c2d12;
    --primary-light: #ea580c;
    --primary-ghost: rgba(124, 45, 18, 0.08);
    --success: #16a34a;
    --shadow: 0 16px 64px rgba(28, 25, 23, 0.12);
    --shadow-sm: 0 4px 16px rgba(28, 25, 23, 0.08);
    font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
    --bg: #1c1917;
    --card: #292524;
    --border: #44403c;
    --text: #fafaf9;
    --muted: #a8a29e;
    --accent: #fafaf9;
    --primary: #ea580c;
    --primary-light: #fb923c;
    --primary-ghost: rgba(234, 88, 12, 0.12);
    --success: #22c55e;
    --shadow: 0 16px 64px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
body { 
    margin: 0; 
    background: var(--bg); 
    color: var(--text);
    transition: background-color 0.3s ease, color 0.3s ease;
}
.shell { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* Modern App Header */
.app-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.brand-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.brand-text h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 11px;
    opacity: 0.85;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.header-nav {
    display: flex;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.nav-icon {
    font-size: 18px;
}

.nav-label {
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #fff;
    color: var(--primary);
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.btn-primary span:first-child {
    font-size: 18px;
    font-weight: 400;
}

.header-menu-dropdown {
    position: relative;
}

.dropdown-content {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    overflow: hidden;
}

.header-menu-dropdown:hover .dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
    border-bottom: 1px solid var(--border);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--primary-ghost);
    color: var(--primary);
}

.dropdown-item span:first-child {
    font-size: 18px;
}

.header-mobile-toggle {
    display: none;
    gap: 8px;
    align-items: center;
}

.hamburger {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.hamburger:hover {
    background: rgba(255, 255, 255, 0.2);
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.mobile-menu {
    display: none;
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 16px;
    gap: 12px;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 99;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.mobile-menu.active {
    display: flex;
}

.mobile-menu .btn,
.mobile-menu .btn-nav,
.mobile-menu a {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 16px;
}

/* Legacy topbar styles (kept for compatibility) */
.topbar-minimal { display: none; }
.topbar-content { display: none; }
.topbar-left { display: none; }
.topbar-right { display: none; }
.topbar-mobile-actions { display: none; }
.btn-nav { padding: 8px 16px; border: 1px solid var(--border); background: var(--card); border-radius: 10px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s ease; color: var(--text); white-space: nowrap; }
.btn-nav:hover { background: var(--primary-ghost); border-color: var(--primary); color: var(--primary); }
.btn-nav.active { background: linear-gradient(135deg, #7c2d12 0%, #ea580c 100%); color: #fff; border-color: var(--primary); }
.theme-toggle { padding: 8px 12px; border: 1px solid var(--border); background: var(--card); border-radius: 10px; cursor: pointer; font-size: 18px; transition: all 0.2s ease; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.theme-toggle:hover { background: var(--primary-ghost); border-color: var(--primary); }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; background: linear-gradient(135deg, #7c2d12 0%, #ea580c 100%); border-radius: 20px; padding: 32px 24px; color: #fff; margin: 0 -24px 24px -24px; box-shadow: var(--shadow-sm); }
.topbar > div h1, .topbar > div .eyebrow, .topbar > div .lede { color: #fff; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; color: rgba(255, 255, 255, 0.8); margin: 0 0 6px; font-weight: 600; }
h1 { margin: 0; font-size: 36px; letter-spacing: -0.03em; font-weight: 700; }
.lede { margin: 8px 0 0; color: rgba(255, 255, 255, 0.9); font-size: 15px; }
.top-actions { display: flex; gap: 12px; }

.grid { display: grid; gap: 18px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin: 0 0 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: var(--shadow-sm); transition: box-shadow 0.3s ease, transform 0.2s ease; }
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.card.stat { background: var(--card); border: 1px solid var(--border); }
.card.wide { grid-column: span 2; }
.stat-row { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.label { margin: 0; color: var(--muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; }
.value { margin: 8px 0 0; font-size: 32px; font-weight: 700; color: var(--primary); }
.chips { list-style: none; padding: 0; margin: 8px 0 0; display: flex; gap: 6px; flex-wrap: wrap; }
.chips li { background: var(--primary-ghost); color: var(--primary); padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); }

/* Controls Bar */
.controls-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; padding: 16px; background: var(--card); border-radius: 14px; border: 1px solid var(--border); flex-wrap: wrap; }
.controls-left { display: flex; gap: 12px; flex: 1; min-width: 280px; align-items: center; }
.controls-right { display: flex; gap: 12px; align-items: center; }
#searchInput { flex: 1; min-width: 200px; padding: 10px 13px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); font-size: 14px; color: var(--text); }
#searchInput:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ghost); }

/* Filters Panel */
.filters-panel { margin-bottom: 24px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow-sm); animation: slideDown 0.3s ease; }
@keyframes slideDown { from { opacity: 0; max-height: 0; } to { opacity: 1; max-height: 500px; } }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
input, select, textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); font-size: 13px; color: var(--text); transition: border-color 0.2s ease, box-shadow 0.2s ease; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ghost); }
.file-label { display: grid; gap: 6px; font-size: 14px; color: var(--text); cursor: pointer; }
.file-label input[type="file"] { padding: 10px 12px; border: 1px dashed var(--primary); border-radius: 10px; background: var(--primary-ghost); }
.file-label input[type="file"]:focus { outline: none; box-shadow: 0 0 0 3px var(--primary-ghost); }
.hint { color: var(--muted); font-size: 12px; font-weight: 500; }

/* Markdown Preview */
.markdown-preview-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.markdown-preview {
    margin-top: 12px;
    padding: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
}

.markdown-preview h1 { font-size: 20px; }
.markdown-preview h2 { font-size: 18px; }
.markdown-preview h3 { font-size: 16px; }
.markdown-preview h4 { font-size: 14px; }

.markdown-preview p {
    margin: 8px 0;
}

.markdown-preview strong {
    font-weight: 700;
    color: var(--text);
}

.markdown-preview em {
    font-style: italic;
}

.markdown-preview code {
    background: var(--primary-ghost);
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.markdown-preview pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 12px 0;
}

.markdown-preview pre code {
    background: none;
    padding: 0;
    color: var(--text);
}

.markdown-preview ul,
.markdown-preview ol {
    margin: 8px 0;
    padding-left: 24px;
}

.markdown-preview li {
    margin: 4px 0;
}

.markdown-preview a {
    color: var(--primary);
    text-decoration: underline;
}

.markdown-preview a:hover {
    color: var(--primary-light);
}

.markdown-preview blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 12px;
    margin: 12px 0;
    color: var(--muted);
    font-style: italic;
}

.markdown-preview hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

.markdown-content {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4 {
    margin-top: 12px;
    margin-bottom: 6px;
    font-weight: 600;
}

.markdown-content p {
    margin: 6px 0;
}

.markdown-content ul,
.markdown-content ol {
    margin: 6px 0;
    padding-left: 20px;
}

.markdown-content code {
    background: var(--primary-ghost);
    color: var(--primary);
    padding: 2px 5px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.markdown-content strong {
    font-weight: 700;
}

.markdown-content a {
    color: var(--primary);
    text-decoration: underline;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: var(--card); border: 1px solid var(--border); border-top: none; border-radius: 0 0 10px 10px; max-height: 200px; overflow-y: auto; z-index: 1000; box-shadow: 0 4px 12px rgba(28, 25, 23, 0.08); }
.autocomplete-item { padding: 10px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border); transition: background 0.15s ease; color: var(--text); }
.autocomplete-item:hover { background: var(--primary-ghost); color: var(--primary); }
.autocomplete-item:last-child { border-bottom: none; }

/* Gallery Grid */
.wines-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; margin-bottom: 40px; }
.wine-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; cursor: pointer; transition: all 0.3s ease; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; height: 100%; }
.wine-card:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.wine-card-image { width: 100%; height: 320px; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; flex-shrink: 0; }
.wine-card-image img { max-width: 100%; max-height: 100%; object-fit: contain; object-position: center; }
.wine-card-image.placeholder { color: var(--muted); font-weight: 700; font-size: 48px; opacity: 0.3; }
.wine-card-body { padding: 12px; display: flex; flex-direction: column; flex: 1; gap: 8px; }
.wine-card-name { margin: 0; font-size: 14px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wine-card-info { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 4px; }
.wine-card-vintage { font-weight: 600; color: var(--primary); }
.wine-card-stock { font-size: 12px; font-weight: 600; color: #16a34a; }
.wine-card-stock.empty { color: #dc2626; }
.wine-card-footer { display: flex; gap: 4px; margin-top: auto; }
.wine-card-action { flex: 1; padding: 6px 8px; font-size: 11px; border: none; border-radius: 6px; background: var(--primary-ghost); color: var(--primary); font-weight: 600; cursor: pointer; transition: all 0.2s ease; }
.wine-card-action:hover { background: var(--primary); color: #fff; }
.wine-card.status-getrunken { opacity: 0.65; }
.wine-card.status-wunschliste { border-color: var(--primary); background: var(--card); }
.wine-card.out-of-stock { opacity: 0.5; filter: grayscale(0.3); }
.wine-card.out-of-stock:hover { opacity: 0.7; }

.wine-separator { grid-column: 1 / -1; text-align: center; position: relative; margin: 24px 0; }

.pill { background: var(--primary-ghost); color: var(--primary); padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; border: 1px solid rgba(124, 45, 18, 0.2); }
.status { padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; text-transform: capitalize; display: inline-block; }
.status.zuhause { background: #dcfce7; color: #14532d; border: 1px solid #a7f3d0; }
.status.getrunken { background: #fee2e2; color: #7c2d12; border: 1px solid #fecaca; }
.status.wunschliste { background: #ede9fe; color: #4c1d95; border: 1px solid #ddd6fe; }
.status.due-soon { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; font-weight: 700; }
.rating { font-weight: 700; color: var(--primary); }
.sub { color: var(--muted); font-size: 12px; line-height: 1.4; }

.btn { border: 1px solid var(--primary); background: var(--primary); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 700; cursor: pointer; transition: all 0.2s ease; font-size: 14px; white-space: nowrap; }
.btn:hover { background: var(--primary-light); border-color: var(--primary-light); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: transparent; color: var(--primary); border-color: var(--border); }
.btn.ghost:hover { background: var(--primary-ghost); border-color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.icon { background: transparent; border: 1px solid var(--border); border-radius: 8px; width: auto; height: auto; padding: 8px 12px; display: flex; align-items: center; gap: 6px; cursor: pointer; transition: all 0.2s ease; font-size: 13px; font-weight: 600; color: var(--primary); }
.btn.icon:hover { background: var(--primary-ghost); border-color: var(--primary); }
.icon { background: transparent; border: 1px solid var(--border); border-radius: 8px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; transition: all 0.2s ease; font-size: 18px; }
.icon:hover { background: var(--primary-ghost); border-color: var(--primary); }

.modal { position: fixed; inset: 0; background: rgba(28, 25, 23, 0.4); display: none; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(4px); z-index: 1000; -webkit-overflow-scrolling: touch; }
.modal[aria-hidden="false"] { display: flex; }
.modal-dialog { background: var(--card); border-radius: 18px; padding: 0; border: 1px solid var(--border); box-shadow: var(--shadow); max-width: 800px; width: 100%; max-height: 90vh; overflow-y: auto; animation: slideUp 0.3s ease; display: flex; flex-direction: column; -webkit-overflow-scrolling: touch; }
 .modal-dialog > form { flex: 1; overflow-y: auto; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px; border-bottom: 1px solid var(--border); background: var(--bg); }
.modal-header h3 { margin: 0; font-size: 18px; font-weight: 700; }
.camera-modal { max-width: 720px; }
.camera-body { padding: 24px; text-align: center; display: grid; gap: 16px; }
#qr-reader { width: 100%; min-height: 320px; background: #000; border-radius: 12px; overflow: hidden; }
.grid.form-grid { padding: 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--text); }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; padding: 16px 20px 0; border-top: 1px solid var(--border); }

/* Wine Form Sections */
.wine-form { padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.form-section { border: none; padding: 18px; background: var(--bg); border-radius: 12px; display: grid; gap: 14px; }
.form-section legend { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: 0.06em; margin-bottom: 6px; padding: 0; }
.form-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.form-section label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--text); }
.form-section input, .form-section select, .form-section textarea { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: var(--card); }
.form-section input:focus, .form-section select:focus, .form-section textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ghost); }
.form-section .file-label { gap: 8px; }
.form-section .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.wine-form > .form-actions { margin: 12px -20px -20px -20px; padding: 16px 20px; border-top: 1px solid var(--border); background: var(--card); border-radius: 0 0 18px 18px; }
/* Ensure form fields fill width */
.wine-form input,
.wine-form select,
.wine-form textarea { width: 100%; box-sizing: border-box; }

.detail-body { display: grid; gap: 0; }
.detail-hero { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: flex-start; padding: 24px; background: var(--bg); border-radius: 16px 16px 0 0; }
.detail-photo { max-width: 100%; max-height: 340px; object-fit: contain; object-position: center; border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); background: var(--bg); padding: 12px; cursor: pointer; transition: opacity 0.2s ease; margin: 0 auto; display: block; }
.detail-photo:hover { opacity: 0.9; }
.lightbox-content { position: relative; }

/* Camera Scanner Modal */
#qr-reader { background: #000 !important; border-radius: 8px; overflow: hidden; }
#qr-reader__scan_region { border: 2px solid var(--primary) !important; }
#qr-reader__toolbar { display: none; }

.detail-hero-body h3 { margin: 0 0 8px; font-size: 26px; line-height: 1.2; letter-spacing: -0.03em; font-weight: 700; color: var(--text); word-wrap: break-word; overflow-wrap: break-word; }
.detail-hero-body .muted { color: var(--muted); font-weight: 600; font-size: 15px; line-height: 1.4; }
.detail-hero-body .eyebrow { margin-bottom: 8px; color: var(--primary); line-height: 1.4; }
.detail-hero-body .sub { line-height: 1.5; word-wrap: break-word; }
.hero-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.detail-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; padding: 24px; border-bottom: 1px solid var(--border); background: var(--card); }
.detail-meta > div { display: grid; gap: 4px; }
.detail-meta strong { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.detail-meta > div > div { font-size: 15px; font-weight: 600; color: var(--text); }
.detail-content { display: grid; gap: 0; }
.detail-section { padding: 24px; display: grid; gap: 12px; background: var(--card); border-bottom: 1px solid var(--border); word-wrap: break-word; overflow-wrap: break-word; }
.detail-section h3 { margin: 0 0 8px; font-size: 14px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.detail-section > div { line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.history { padding: 24px; display: grid; gap: 12px; background: var(--card); }
.history h4 { margin: 0 0 8px; font-size: 14px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.history-list { display: grid; gap: 12px; }
.history-item { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); transition: all 0.2s ease; word-wrap: break-word; overflow-wrap: break-word; }
.history-item:hover { background: var(--primary-ghost); border-color: var(--primary); }
.history-item strong { color: var(--text); font-weight: 700; display: block; margin-bottom: 6px; }
.history-item > div { line-height: 1.5; margin-bottom: 6px; word-break: break-word; }
.history-item > div:last-child { margin-bottom: 0; }
.purchase-item { background: var(--primary-ghost); border-color: var(--primary); }

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .shell { padding: 12px; }
    
    /* Modern Header Mobile */
    .header-container {
        padding: 12px 16px;
        gap: 12px;
    }
    
    .brand-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .brand-text h1 {
        font-size: 16px;
    }
    
    .brand-subtitle {
        display: none;
    }
    
    .header-nav,
    .header-actions {
        display: none;
    }
    
    .header-mobile-toggle {
        display: flex;
    }
    
    .mobile-menu .btn-nav {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 14px;
        font-size: 15px;
    }
    
    .btn { min-height: 48px; padding: 12px 20px; font-size: 15px; }
    .btn.icon { min-width: 48px; min-height: 48px; padding: 12px; font-size: 16px; }
    .btn.ghost, .btn.primary { min-height: 48px; font-size: 15px; font-weight: 600; }
    .theme-toggle { min-width: 48px; min-height: 48px; }
    
    .topbar { margin: 0 -12px 16px -12px; padding: 16px 12px; flex-direction: column; align-items: flex-start; }
    h1 { font-size: 24px; }
    .top-actions { width: 100%; }

    /* Modals full-screen on mobile/tablet */
    .modal { padding: 0; align-items: stretch; justify-content: flex-start; }
    .modal-dialog { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .modal-header { position: sticky; top: 0; z-index: 2; padding: 16px; background: var(--card); border-bottom: 1px solid var(--border); }
    .modal-header h3 { font-size: 18px; }
    .modal-header .icon { min-width: 44px; min-height: 44px; font-size: 24px; }
    .wine-form { padding: 16px; }
    .form-section { padding: 14px; }
    .form-section legend { font-size: 13px; }
    .wine-form > .form-actions { margin: 0; border-radius: 0; padding: 16px; gap: 12px; }
    .form-actions .btn { flex: 1; min-width: 0; }

    /* Camera modal: maximize viewport and keep reader visible */
    .camera-modal { max-width: 100vw; height: 100vh; max-height: 100vh; }
    .camera-body { padding: 16px; gap: 12px; }
    #qr-reader { min-height: 55vh; border-radius: 0; }

    .controls-bar { flex-direction: column; align-items: stretch; padding: 12px; margin-bottom: 16px; }
    .controls-left { min-width: unset; flex-direction: column; width: 100%; }
    .controls-right { width: 100%; flex-wrap: wrap; }
    #searchInput { width: 100%; min-height: 48px; font-size: 16px; padding: 12px 16px; }

    .stats { grid-template-columns: 1fr; }
    .card.wide { grid-column: auto; }
    .stat-row { flex-direction: column; }
    
    .wines-gallery { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    .wine-card-image { height: 240px; }
    .wine-card-body { padding: 12px; }
    .wine-card-name { font-size: 14px; }
    .wine-card-action { font-size: 12px; padding: 8px 10px; min-height: 40px; }
    
    .filter-grid { grid-template-columns: 1fr; gap: 12px; }
    .filters-panel { padding: 12px; }
    
    .detail-hero { grid-template-columns: 1fr; gap: 20px; padding: 16px; }
    .detail-hero-body h3 { font-size: 20px; margin-bottom: 10px; }
    .detail-hero-body .sub { font-size: 15px; }
    .detail-photo { height: 300px; margin-bottom: 12px; }
    .detail-meta { grid-template-columns: repeat(2, 1fr); gap: 14px; padding: 16px; font-size: 14px; }
    .detail-meta > div > div { font-size: 14px; }
    .detail-section { padding: 16px; }
    .detail-section > div { font-size: 15px; line-height: 1.7; }
    /* Mobile: Action buttons in column layout with proper spacing */
    .detail-section .actions { flex-direction: column; gap: 10px; }
    .detail-section .btn { width: 100%; justify-content: center; min-height: 48px; font-size: 15px; font-weight: 600; }
    .history { padding: 16px; }
    .history-item { padding: 14px; font-size: 15px; }
    .history-item strong { font-size: 15px; margin-bottom: 8px; }
    .hero-tags { gap: 6px; }
    .hero-tags .pill { font-size: 11px; padding: 4px 10px; }
    
    input, select, textarea { min-height: 48px; font-size: 16px; padding: 12px 16px; }
}

@media (max-width: 480px) {
    .shell { padding: 10px; }
    .topbar-minimal { padding: 8px 10px; }
    .topbar-left h1 { font-size: 14px; }
    
    .wines-gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .wine-card-image { height: 200px; }
    .wine-card-body { padding: 10px; }
    .wine-card-name { font-size: 13px; }
    .wine-card-action { font-size: 11px; padding: 6px 8px; }
}
