/* Растём вместе — Mobile-First Responsive Design */
/* Оптимизировано для iPhone 15/16, Safari, viewport-based адаптация */

:root {
  --bg: #f7f5f0; --surface: #fffdf8; --card: #fffaf3; --border: #e8e0d4;
  --text: #3d3528; --muted: #8a7d6a; --primary: #7ba87b; --primary-d: #5e8a5e;
  --accent: #d4a574; --danger: #c47a6a; --warning: #d4a84a; --success: #7ba87b;
  --radius: 14px; --shadow: 0 2px 8px rgba(61,53,40,0.06);
  --shadow-lg: 0 4px 16px rgba(61,53,40,0.1);
  --nav-h: 56px; --max-w: 960px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --touch-min: 44px;
}
[data-theme="dark"] {
  --bg: #1e1c18; --surface: #2a2722; --card: #302d27; --border: #3d3933;
  --text: #e8e0d4; --muted: #a89a85; --primary: #8bbf8b; --primary-d: #6fa06f;
  --accent: #d4b080; --danger: #d48a7a; --warning: #d4b85a; --success: #8bbf8b;
  --shadow: 0 2px 8px rgba(0,0,0,0.2); --shadow-lg: 0 4px 16px rgba(0,0,0,0.3);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; font-size: clamp(16px, 4vw, 17px); min-height: 100vh; min-height: 100dvh; padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); word-wrap: break-word; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
a { color: var(--primary-d); text-decoration: none; -webkit-touch-callout: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
button, .btn, [role="button"] { min-height: var(--touch-min); min-width: var(--touch-min); display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; border: none; border-radius: var(--radius); font-size: 16px; cursor: pointer; transition: opacity 0.2s ease, transform 0.1s ease; text-decoration: none; touch-action: manipulation; -webkit-appearance: none; appearance: none; }
button:active, .btn:active { transform: scale(0.98); }
button:focus-visible, .btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: 6px 12px; font-size: 14px; min-height: 36px; min-width: 36px; }
.btn-full { width: 100%; }
.btn-fav-active { background: var(--accent); color: #fff; }
.navbar { background: var(--surface); border-bottom: 1px solid var(--border); height: calc(var(--nav-h) + var(--safe-top)); padding-top: var(--safe-top); position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); background-color: color-mix(in srgb, var(--surface) 85%, transparent); }
.nav-container { max-width: var(--max-w); margin: 0 auto; display: flex; align-items: center; height: 100%; padding: 0 calc(16px + var(--safe-left)) 0 calc(16px + var(--safe-right)); gap: 12px; }
.nav-brand { font-size: 18px; font-weight: 700; color: var(--text); white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.nav-icon { font-size: 20px; }
.nav-menu { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav-menu a { padding: 8px 12px; border-radius: 8px; font-size: 15px; color: var(--text); min-height: var(--touch-min); display: inline-flex; align-items: center; }
.nav-menu a:hover { background: var(--card); text-decoration: none; }
.nav-admin { color: var(--primary-d) !important; font-weight: 600; }
.nav-logout { color: var(--danger) !important; }
.nav-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); min-width: var(--touch-min); min-height: var(--touch-min); padding: 0; align-items: center; justify-content: center; }
.theme-toggle { background: none; border: none; font-size: 20px; cursor: pointer; padding: 6px; border-radius: 8px; min-width: var(--touch-min); min-height: var(--touch-min); display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle:hover { background: var(--card); }
@media (max-width: 768px) { .nav-toggle { display: inline-flex; } .nav-menu { display: none; position: absolute; top: calc(var(--nav-h) + var(--safe-top)); left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; padding: 12px 16px; box-shadow: var(--shadow-lg); max-height: calc(100vh - var(--nav-h) - var(--safe-top)); overflow-y: auto; -webkit-overflow-scrolling: touch; } .nav-menu.open { display: flex; } .nav-menu a { padding: 14px 16px; width: 100%; justify-content: flex-start; } }
.container { max-width: var(--max-w); margin: 0 auto; padding: 20px calc(16px + var(--safe-left)) calc(60px + var(--safe-bottom)) calc(16px + var(--safe-right)); min-height: calc(100vh - var(--nav-h) - var(--safe-top) - var(--safe-bottom) - 120px); min-height: calc(100dvh - var(--nav-h) - var(--safe-top) - var(--safe-bottom) - 120px); }
.flash { padding: 12px 16px; border-radius: var(--radius); margin: 10px 0; font-size: 15px; word-wrap: break-word; }
.flash-success { background: var(--primary); color: #fff; }
.flash-error { background: var(--danger); color: #fff; }
.flash-info { background: var(--accent); color: #fff; }
.flash-warning { background: var(--warning); color: #fff; }
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-field label { font-size: 14px; color: var(--muted); font-weight: 600; }
.form-field input, .form-field textarea, .form-field select { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 16px; background: var(--bg); color: var(--text); min-height: var(--touch-min); width: 100%; -webkit-appearance: none; appearance: none; }
.form-field input:focus, .form-field textarea:focus, .form-field select:focus { outline: 2px solid var(--primary); border-color: var(--primary); outline-offset: 1px; }
input[type="email"], input[type="tel"], input[type="url"] { -webkit-appearance: none; border-radius: 10px; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; margin-right: 8px; accent-color: var(--primary); }
.card-list { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); transition: box-shadow 0.2s ease, transform 0.1s ease; word-wrap: break-word; }
.card:hover { box-shadow: var(--shadow-lg); text-decoration: none; transform: translateY(-2px); }
@media (prefers-reduced-motion: reduce) { .card:hover { transform: none; } }
.card h3 { font-size: 18px; margin-bottom: 6px; color: var(--text); word-wrap: break-word; }
.card p { color: var(--muted); font-size: 15px; }
.card-sm { padding: 12px; }
.card-cat { display: inline-block; background: var(--border); padding: 4px 12px; border-radius: 20px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.card-meta, .card-date { font-size: 13px; color: var(--muted); }
.home-hero { margin-bottom: 24px; }
.hero-greeting h1 { font-size: clamp(24px, 6vw, 28px); margin-bottom: 12px; word-wrap: break-word; }
.age-card { display: flex; align-items: center; gap: 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); }
.age-icon { font-size: 36px; }
.age-label { font-size: 14px; color: var(--muted); }
.age-value { font-size: 22px; font-weight: 700; }
.tip-card { display: flex; align-items: center; gap: 16px; background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 16px 20px; margin: 16px 0; box-shadow: var(--shadow); }
.tip-icon { font-size: 28px; }
.tip-label { font-size: 13px; color: var(--muted); }
.tip-text { font-size: 16px; }
.tip-refresh { margin-left: auto; }
.quick-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.quick-btn { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 10px 16px; font-size: 15px; color: var(--text); box-shadow: var(--shadow); min-height: var(--touch-min); display: inline-flex; align-items: center; }
.quick-btn:hover { background: var(--primary); color: #fff; text-decoration: none; }
.home-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; margin-top: 20px; }
.home-section h2 { font-size: 20px; margin-bottom: 12px; }
.home-side { display: flex; flex-direction: column; gap: 24px; }
.badge { background: var(--primary); color: #fff; padding: 2px 8px; border-radius: 12px; font-size: 13px; }
.stats-row { display: flex; gap: 12px; }
.stat-item { flex: 1; text-align: center; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.stat-num { display: block; font-size: 24px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--muted); }
.random-tip-section { margin-top: 24px; text-align: center; }
.random-tip-display { margin-top: 12px; font-size: 17px; color: var(--muted); min-height: 24px; }
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; background: var(--bg); padding: 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px; max-width: 400px; width: 100%; box-shadow: var(--shadow-lg); }
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-icon { font-size: 40px; }
.auth-header h1 { font-size: 24px; margin: 8px 0 4px; }
.auth-header p { font-size: 14px; color: var(--muted); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-footer { text-align: center; margin-top: 16px; }
.auth-link { text-align: center; margin-top: 16px; font-size: 15px; }
.theme-toggle-inline { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; cursor: pointer; color: var(--text); font-size: 14px; min-height: var(--touch-min); }
.article { max-width: 720px; margin: 0 auto; }
.article-header { margin-bottom: 20px; }
.back-link { font-size: 14px; color: var(--muted); display: inline-block; padding: 4px 0; min-height: var(--touch-min); align-items: center; }
.article-header h1 { font-size: clamp(22px, 5vw, 26px); margin: 8px 0 12px; word-wrap: break-word; }
.article-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.article-date { font-size: 13px; color: var(--muted); }
.article-summary { font-size: 18px; color: var(--muted); margin: 16px 0; font-style: italic; }
.article-body { font-size: 17px; line-height: 1.8; margin: 16px 0; word-wrap: break-word; }
.article-section { margin: 24px 0; padding: 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.article-section h2 { font-size: 19px; margin-bottom: 10px; word-wrap: break-word; }
.article-warning { border-left: 4px solid var(--warning); }
.article-specialist { border-left: 4px solid var(--danger); }
.article-actions { margin: 24px 0; display: flex; gap: 12px; flex-wrap: wrap; }
.phrase-list { list-style: none; padding: 0; }
.phrase-list li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 16px; }
.phrase-list li:last-child { border-bottom: none; }
.phrase-group { margin: 20px 0; }
.phrase-group h2 { font-size: 19px; margin-bottom: 10px; }
.notes-list { display: flex; flex-direction: column; gap: 12px; }
.note-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.note-card h3 { font-size: 17px; margin-bottom: 8px; }
.note-content { font-size: 16px; margin: 8px 0; }
.note-date { font-size: 13px; color: var(--muted); }
.admin-stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 20px 0; }
.stat-card { flex: 1; min-width: 120px; text-align: center; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.admin-section { margin: 24px 0; padding: 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.admin-section h2 { font-size: 19px; margin-bottom: 12px; }
.admin-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 15px; overflow-x: auto; display: block; }
.admin-table thead { display: table-header-group; }
.admin-table tbody { display: table-row-group; }
.admin-table th { text-align: left; padding: 10px 8px; border-bottom: 2px solid var(--border); color: var(--muted); font-size: 14px; white-space: nowrap; }
.admin-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.admin-form { display: flex; flex-direction: column; gap: 16px; max-width: 680px; }
.inline-form { flex-direction: row; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.form-field-inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.form-field-inline input { padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 16px; background: var(--bg); color: var(--text); }
.admin-links { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0; }
.error-page { text-align: center; padding: 60px 20px; }
.error-page h1 { font-size: 48px; margin-bottom: 12px; }
.error-page p { font-size: 18px; color: var(--muted); margin-bottom: 20px; }
.footer { text-align: center; padding: 20px 16px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.footer p { margin: 4px 0; }
.footer-copy { font-size: 12px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 24px; }
.page-intro { color: var(--muted); margin-bottom: 16px; font-size: 16px; }
.empty-text { color: var(--muted); font-size: 16px; padding: 20px; text-align: center; }
.search-form { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 200px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 17px; background: var(--bg); color: var(--text); min-height: var(--touch-min); }
.note-form textarea { width: 100%; min-height: 120px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 16px; background: var(--bg); color: var(--text); resize: vertical; }
@media (max-width: 390px) { .home-grid { grid-template-columns: 1fr; } .stats-row { flex-wrap: wrap; } .stat-item { min-width: calc(50% - 6px); } .age-card { flex-direction: column; text-align: center; } .tip-card { flex-direction: column; text-align: center; } .tip-refresh { margin-left: 0; } .article-actions { flex-direction: column; } .article-actions .btn { width: 100%; } }
@media (min-width: 391px) and (max-width: 430px) { .container { padding: 20px 20px calc(60px + var(--safe-bottom)) 20px; } .hero-greeting h1 { font-size: 26px; } .article-header h1 { font-size: 24px; } }
@media (min-width: 431px) and (max-width: 768px) { .container { padding: 20px 24px calc(60px + var(--safe-bottom)) 24px; } .hero-greeting h1 { font-size: 28px; } }
@media (min-width: 769px) and (max-width: 1024px) { .container { padding: 24px 32px 60px 32px; } .home-grid { grid-template-columns: 3fr 1fr; } .admin-table { display: table; } }
@media (min-width: 1025px) { .container { padding: 32px 40px 60px 40px; } .home-grid { grid-template-columns: 2fr 1fr; } }
@media (max-width: 768px) and (orientation: landscape) { .navbar { height: calc(48px + var(--safe-top)); } .nav-menu { padding: 8px 16px; } .container { min-height: calc(100dvh - 48px - var(--safe-top) - var(--safe-bottom) - 80px); } .hero-greeting h1 { font-size: 22px; } .age-card { padding: 12px 16px; } .tip-card { padding: 12px 16px; } }
@media (max-width: 768px) { .nav-toggle { display: inline-flex; } .nav-menu { display: none; } .nav-menu.open { display: flex; } .home-grid { grid-template-columns: 1fr; } .stats-row { flex-wrap: wrap; } .stat-item { min-width: calc(50% - 6px); } .admin-table { font-size: 13px; } .admin-table th, .admin-table td { padding: 6px 4px; } .article-header h1 { font-size: 22px; } .hero-greeting h1 { font-size: 22px; } body { font-size: 16px; } .admin-stats { flex-direction: column; } .stat-card { min-width: 100%; } }
@media (max-width: 374px) { .nav-brand span { display: none; } .quick-nav { gap: 6px; } .quick-btn { padding: 8px 12px; font-size: 14px; } .card { padding: 12px; } .article-body { font-size: 16px; } }
@media print { .navbar, .nav-toggle, .theme-toggle, .footer, .btn, .article-actions { display: none !important; } body { background: #fff; color: #000; font-size: 12pt; } .container { padding: 0; max-width: none; } .card { box-shadow: none; border: 1px solid #ccc; } a { color: #000; text-decoration: underline; } }
.break-word { word-wrap: break-word; overflow-wrap: break-word; word-break: break-word; hyphens: auto; -webkit-hyphens: auto; }
img, video, pre, code { max-width: 100%; height: auto; }
pre { white-space: pre-wrap; word-wrap: break-word; overflow-x: auto; -webkit-overflow-scrolling: touch; }
*:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; top: -40px; left: 0; background: var(--primary); color: #fff; padding: 8px 16px; z-index: 200; transition: top 0.3s; }
.skip-link:focus { top: 0; }

/* iPhone 15/16 Specific Optimizations */
/* iPhone 15: 393x852, iPhone 16: 402x852, iPhone 16 Pro Max: 430x932 */

@media (min-width: 393px) and (max-width: 394px) {
    .container { padding: 20px 18px calc(60px + var(--safe-bottom)) 18px; }
    .hero-greeting h1 { font-size: 25px; }
    .article-header h1 { font-size: 23px; }
}

@media (min-width: 402px) and (max-width: 403px) {
    .container { padding: 20px 20px calc(60px + var(--safe-bottom)) 20px; }
    .nav-menu a { padding: 10px 14px; }
}

@media (min-width: 428px) and (max-width: 432px) {
    .container { padding: 20px 24px calc(60px + var(--safe-bottom)) 24px; }
    .home-grid { grid-template-columns: 1fr; }
    .stats-row { flex-wrap: wrap; }
    .stat-item { min-width: calc(50% - 6px); }
}

@supports (-webkit-touch-callout: none) {
    .navbar { padding-left: max(16px, var(--safe-left)); padding-right: max(16px, var(--safe-right)); }
    .container { padding-left: max(16px, var(--safe-left)); padding-right: max(16px, var(--safe-right)); }
}

@media (max-height: 500px) and (orientation: landscape) {
    .auth-card { padding: 20px 24px; max-width: 500px; }
    .hero-greeting { margin-bottom: 12px; }
    .tip-card { padding: 10px 14px; }
}
