
:root {
  --bg: #f7f5f1;
  --card: #ffffff;
  --text: #1f1b14;
  --muted: #7b7468;
  --border: #e8e0d0;
  --primary: #c9a64b;
  --primary-dark: #9e7c28;
  --success: #167f63;
  --danger: #db5b5b;
  --soft: #f5eee2;
  --soft-2: #eef6f3;
  --shadow: 0 14px 36px rgba(47, 39, 20, 0.08);
  --container: 1180px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Tajawal', sans-serif;
  background: linear-gradient(180deg, #fbfaf7 0%, #f2eee7 100%);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
.container { width: min(100% - 32px, var(--container)); margin: auto; }
.topbar {
  border-bottom: 1px solid rgba(201,166,75,.18);
  background: rgba(255,255,255,.80);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 0;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; }
.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
  flex-shrink: 0;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.brand-text strong { display: block; font-size: 1.08rem; }
.brand-text span { color: var(--muted); font-size: .92rem; }
.nav { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.nav a {
  color: var(--text); font-weight: 700; background: #fff; border: 1px solid #e6dcc4; border-radius: 999px;
  font-size: .92rem; padding: 10px 14px; box-shadow: 0 8px 20px rgba(47,39,20,.06); white-space: nowrap;
}
.nav a:hover, .nav a.active { color: var(--primary-dark); border-color: #d8be79; background: #fbf5e1; }
.page { padding: 34px 0 60px; }
.head { margin-bottom: 20px; }
.head h1 { margin: 0 0 10px; font-size: clamp(2rem, 4vw, 3rem); }
.head p { margin: 0; color: var(--muted); line-height: 1.9; }
.card {
  background: rgba(255,255,255,.94); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: 28px; padding: 26px;
}
.section-title { margin: 0 0 8px; font-size: 1.35rem; }
.section-update { color: var(--muted); font-size: .92rem; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field label { display: block; margin-bottom: 10px; font-weight: 800; font-size: 1rem; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid #d9d1bf; background: #fff; border-radius: 14px; padding: 15px 16px;
  font-size: 1rem; outline: none; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #cdb05d; box-shadow: 0 0 0 4px rgba(201,166,75,.12);
}
.summary { display: grid; gap: 14px; margin-top: 22px; }
.summary-box {
  border-radius: 16px; padding: 18px 20px; font-weight: 800; display: flex; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; align-items: center;
}
.summary-box.base { background: #f6efea; color: #ff7a21; }
.summary-box.soft { background: #f5eee2; color: #8b6330; }
.summary-box.result { background: #eff5f2; color: var(--success); font-size: 1.12rem; }
.summary-box.warn { background: #fff1f1; color: var(--danger); font-size: 1.12rem; }
.helper, .foot-note {
  margin-top: 18px; color: var(--muted); line-height: 1.9; background: #fff; border: 1px dashed #dfd4bd;
  border-radius: 16px; padding: 16px 18px;
}
.btn-add, .btn-primary {
  width: 100%; border: 1px solid #1a8d7c; background: #fff; color: #1a8d7c; border-radius: 16px;
  padding: 16px; font-size: 1.05rem; font-weight: 800; cursor: pointer; margin-top: 18px;
}
.btn-add:hover, .btn-primary:hover { background: #f1fbf8; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { padding: 15px 12px; text-align: right; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: .95rem; font-weight: 800; }
td.current-price { font-size: 1.14rem; font-weight: 400; }
.change.up { color: var(--success); font-weight: 800; }
.change.down { color: var(--danger); font-weight: 800; }
.tools-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.tool-card {
  background: #ffffff; border: 1px solid #e6dcc4; box-shadow: 0 10px 30px rgba(47, 39, 20, 0.08);
  border-radius: 22px; padding: 24px 20px; text-align: center; position: relative;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.tool-card:hover { transform: translateY(-4px); box-shadow: 0 16px 34px rgba(47, 39, 20, 0.12); border-color: #d8be79; }
.tool-card h3 {
  line-height: 1.4; display: inline-flex; align-items: center; justify-content: center; width: 100%;
  padding: 12px 16px; border-radius: 999px; background: #f3ead2; color: #9e7c28; margin: 0 0 18px;
  font-size: 1.02rem; font-weight: 800; min-height: 58px;
}
.tool-card p { color: #6e675d; line-height: 1.95; margin: 8px 0 0; }
.footer { padding: 34px 0 44px; color: var(--muted); }
.footer-inner {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 24px;
}
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; font-weight: 700; }
.note { color: var(--muted); line-height: 1.9; }
.rows { display: grid; gap: 18px; }
.row-card { background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 18px; }
.row-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; color: var(--muted); font-weight: 700; }
.remove-btn { background: transparent; border: 0; color: var(--danger); font-weight: 800; cursor: pointer; padding: 0; }
.chart-box {
  background: rgba(255,255,255,.94); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: 28px; padding: 22px;
}
.chart-controls { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; margin-bottom: 16px; }
.chart-placeholder {
  height: 380px; border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(201,166,75,0.10), rgba(201,166,75,0.02)),
    repeating-linear-gradient(to right, rgba(110,103,93,0.07), rgba(110,103,93,0.07) 1px, transparent 1px, transparent 72px),
    repeating-linear-gradient(to bottom, rgba(110,103,93,0.06), rgba(110,103,93,0.06) 1px, transparent 1px, transparent 68px),
    #fff;
  position: relative; overflow: hidden; padding: 14px;
}
.chart-canvas-wrap { position: relative; width: 100%; height: 100%; border-radius: 18px; overflow: hidden; }
#goldChart { width: 100%; height: 100%; display: block; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 700; pointer-events: none; }
@media (max-width: 1180px) {
  .nav { gap: 8px; flex-wrap: wrap; }
  .nav a { font-size: .84rem; padding: 9px 11px; }
}
@media (max-width: 1080px) {
  .tools-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 720px) {
  .topbar-inner { align-items: start; flex-direction: column; }
  .nav { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .nav a { text-align: center; white-space: normal; line-height: 1.35; }
  .grid-2, .chart-controls, .tools-grid { grid-template-columns: 1fr; }
  .card, .chart-box { padding: 18px; }
  table { min-width: 620px; }
}

@media (max-width: 720px) {
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255,255,255,.92);
  }
  table {
    min-width: 560px;
    width: 100%;
  }
  thead {
    display: table-header-group;
  }
  tbody {
    display: table-row-group;
  }
  tbody tr {
    display: table-row;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
  }
  tbody td {
    display: table-cell;
    padding: 13px 10px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    white-space: nowrap;
  }
  tbody td::before {
    content: none !important;
  }
  th {
    font-size: .86rem;
    white-space: nowrap;
  }
  td {
    font-size: .92rem;
  }
  td.current-price {
    font-size: 1.06rem;
    font-weight: 400;
  }
}

/* v8 floating controls fix */
.floating-controls {
  position: fixed;
  top: 88px;
  left: 16px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}
.floating-controls .lang-toggle,
.floating-controls .theme-toggle {
  position: static !important;
  inset: auto !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 44px;
  padding: 10px 14px;
  margin: 0;
}
@media (max-width:720px){
  .floating-controls{
    top:auto;
    bottom:16px;
    left:16px;
  }
}

.update-meta{margin:6px 0 0;color:#8a8276;font-size:.92rem;font-weight:500;}

.table-wrap td:nth-child(2){font-weight:400 !important;}
.table-wrap td:nth-child(2) strong{font-weight:400 !important;}

.floating-controls {
  position: fixed;
  top: 88px;
  left: 16px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}
.floating-controls .lang-toggle,
.floating-controls .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #e6dcc4;
  background: rgba(255,255,255,.94);
  color: var(--text);
  border-radius: 999px;
  font-size: .84rem;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(47,39,20,.10);
  cursor: pointer;
  transition: .2s ease;
}
.floating-controls .lang-toggle:hover,
.floating-controls .theme-toggle:hover {
  background: #fbf5e1;
  color: var(--primary-dark);
  border-color: #d8be79;
}
body.theme-dark .floating-controls .lang-toggle,
body.theme-dark .floating-controls .theme-toggle {
  background: rgba(28,28,28,.94);
  border-color: var(--border);
}
@media (max-width: 720px) {
  .floating-controls {
    top: auto;
    bottom: 16px;
    left: 16px;
  }
}


/* v15 dark theme */
body.theme-dark {
  --text: #f2ede3;
  --muted: #b8b1a4;
  --border: #3a3428;
  --card: #171512;
  background: linear-gradient(180deg, #11100e 0%, #1a1815 100%);
  color: var(--text);
}
body.theme-dark .topbar {
  background: rgba(20,18,16,.88);
  border-bottom-color: rgba(201,166,75,.16);
}
body.theme-dark .nav a,
body.theme-dark .tool-card,
body.theme-dark .card,
body.theme-dark .row-card,
body.theme-dark .chart-box,
body.theme-dark .table-wrap,
body.theme-dark .helper,
body.theme-dark .foot-note,
body.theme-dark .field input,
body.theme-dark .field select,
body.theme-dark .field textarea,
body.theme-dark table,
body.theme-dark .summary-box.soft,
body.theme-dark .summary-box.base,
body.theme-dark .summary-box.result,
body.theme-dark .summary-box.warn {
  background-color: #1c1916;
  color: var(--text);
  border-color: var(--border);
}
body.theme-dark .summary-box.base { background: #2b2118; color: #f7b56c; }
body.theme-dark .summary-box.soft { background: #241f19; color: #dbc6a0; }
body.theme-dark .summary-box.result { background: #172620; color: #8ce0bf; }
body.theme-dark .summary-box.warn { background: #2b1717; color: #ffb0b0; }
body.theme-dark .tool-card h3 { background: #2a241b; color: #e5c57c; }
body.theme-dark .brand-text span,
body.theme-dark .head p,
body.theme-dark .note,
body.theme-dark .section-update,
body.theme-dark th,
body.theme-dark .row-meta,
body.theme-dark .footer,
body.theme-dark .tool-card p,
body.theme-dark .summary-box small { color: var(--muted); }
body.theme-dark th, body.theme-dark td { border-bottom-color: var(--border); }
body.theme-dark .nav a:hover,
body.theme-dark .nav a.active,
body.theme-dark .floating-controls .lang-toggle:hover,
body.theme-dark .floating-controls .theme-toggle:hover {
  background: #2a241b;
  color: #e5c57c;
  border-color: #7d6430;
}
body.theme-dark .field input:focus,
body.theme-dark .field select:focus,
body.theme-dark .field textarea:focus { box-shadow: 0 0 0 4px rgba(201,166,75,.18); }
body.theme-dark .btn-add, body.theme-dark .btn-primary {
  background: #171512; color: #74d0bb; border-color: #2b8a77;
}
body.theme-dark .btn-add:hover, body.theme-dark .btn-primary:hover { background: #11221e; }
body.theme-dark .floating-controls .lang-toggle,
body.theme-dark .floating-controls .theme-toggle { background: rgba(28,28,28,.94); border-color: var(--border); color: var(--text); }


.page {
  padding: 34px 0 60px;
}

.hero {
  margin-bottom: 22px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.9;
  max-width: 760px;
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.post-card {
  background: rgba(255,255,255,.94);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 24px;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.post-card:hover {
  transform: translateY(-4px);
  border-color: #d8be79;
  box-shadow: 0 18px 40px rgba(47,39,20,.12);
}

.post-thumb {
  position: relative;
  display: block;
  height: 190px;
  background: linear-gradient(135deg, #f5e7bf, #c9a64b);
  overflow: hidden;
}

.post-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(31,27,20,0.02), rgba(31,27,20,0.18));
  pointer-events: none;
}

.post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 28px;
  display: block;
  opacity: .95;
}

.post-thumb-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  color: #8d6b1d;
  font-size: .84rem;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(47,39,20,.08);
}

.post-body {
  padding: 22px;
}

.post-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border-radius: 999px;
  background: #f3ead2;
  color: #9e7c28;
  margin-bottom: 16px;
  font-size: .88rem;
  font-weight: 800;
}

.post-card h3 {
  margin: 0 0 12px;
  line-height: 1.6;
  font-size: 1.2rem;
}

.post-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.9;
  font-size: .98rem;
}

.post-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, #e2c46c, #a78026);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(167,128,38,.22);
}

.post-link:hover {
  transform: translateY(-1px);
}

@media (max-width: 1080px) {
  .blog-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .blog-grid {
    grid-template-columns: 1fr;
  }

  .post-thumb {
    height: 170px;
  }
}
/* Blog & Articles Dark Mode Fix */
body.theme-dark .post-card,
body.theme-dark .article-card {
  background: #17130f;
  border-color: #2d2418;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

body.theme-dark .post-card h3,
body.theme-dark .article-card h1,
body.theme-dark .article-content h2,
body.theme-dark .article-content p,
body.theme-dark .article-content li,
body.theme-dark .post-card p {
  color: #f3ede4;
}

body.theme-dark .hero h1,
body.theme-dark .hero p,
body.theme-dark .article-intro {
  color: #f3ede4;
}

body.theme-dark .post-tag,
body.theme-dark .article-meta span,
body.theme-dark .post-thumb-badge {
  background: #2b2318;
  color: #e0c26c;
  border-color: #3a2f20;
}

body.theme-dark .post-link,
body.theme-dark .cta-links a {
  background: #2b2318;
  color: #f1d27b;
  border-color: #4b3a20;
  box-shadow: none;
}

body.theme-dark .post-link:hover,
body.theme-dark .cta-links a:hover {
  background: #3a2f20;
  color: #ffd97f;
}

body.theme-dark .cta-box {
  background: #1d1812;
  border-color: #3b3020;
}

body.theme-dark .cta-box p {
  color: #d9cfc0;
}

body.theme-dark .post-thumb {
  background: linear-gradient(135deg, #4a3817, #8f6920);
}

body.theme-dark .post-thumb::after {
  background: linear-gradient(180deg, rgba(0,0,0,0.05), rgba(0,0,0,0.22));
}