  /* ── Load Fonts ── */
  @font-face {
      font-family: 'DM Mono';
      font-weight: 400;
      src: url('fonts/dmmono-400.ttf') format('ttf');
    }

    @font-face {
      font-family: 'DM Mono';
      font-weight: 500;
      src: url('fonts/dmmono-500.ttf') format('ttf');
    }

    @font-face {
      font-family: 'Lora';
      font-weight: 400;
      src: url('fonts/lora-400.ttf') format('.ttf');
    }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    
    :root {
      --bg:          #f5f2eb;
      --surface:     #ffffff;
      --surface-2:   #faf8f4;
      --border:      #d9d3c7;
      --ink:         #1c1814;
      --ink-muted:   #6b6155;
      --accent:      #5844E3;
      --accent-dark: #4232c4;
      --accent-lt:   #eeebfb;
      --radius:      10px;
      --shadow:      0 2px 16px rgba(0,0,0,.07);
      --max-w:       760px;
    }

    body {
      font-family: 'Lora', Georgia, serif;
      background: var(--bg);
      color: var(--ink);
      min-height: 100vh;
      line-height: 1.6;
    }

    /* ── Layout ── */
    .container {
      max-width: var(--max-w);
      margin: 0 auto;
      padding: 0 1.5rem;
    }

    main { flex: 1; }

    /* ── Header ── */
    header {
      position: sticky;
      top: 0;
      z-index: 10;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.9rem 2rem;
      border-bottom: 1px solid var(--border);
      background: var(--surface);
    }

    header a {
      font-family: 'DM Mono', monospace;
      font-size: .85rem;
      color: var(--accent);
      text-decoration: none;
      letter-spacing: .05em;
    }

    header .wordmark {
      font-family: 'DM Mono', monospace;
      font-size: 1rem;
      font-weight: 500;
      color: var(--accent);
      letter-spacing: .06em;
      text-decoration: none;
    }

    header nav {
      display: flex;
      align-items: center;
      gap: .75rem;
    }

    header img {
      display: block;
      height: 40px;
      width: auto;
      object-fit: contain;
    }

    header .logo a {
      display: flex;
      align-items: center;
      text-decoration: none;
    }

    .header-spacing {
      margin-bottom: 200px;
    }
    /* ── Hero ── */
    .hero {
      padding: 5rem 1.5rem 4.5rem;
      text-align: center;
    }

    .hero h1 {
      font-size: clamp(2rem, 5vw, 3rem);
      font-weight: 600;
      line-height: 1.2;
      letter-spacing: -.01em;
      max-width: 600px;
      margin: 0 auto 1rem;
      color: var(--ink);
    }

    .hero h1 em {
      font-style: italic;
      color: var(--accent);
    }

    .hero-sub {
      font-size: 1.05rem;
      color: var(--ink-muted);
      max-width: 460px;
      margin: 0 auto 2.5rem;
      line-height: 1.7;
    }

    .hero-actions {
      display: flex;
      align-items: center;
      justify-content: center;
      flex-wrap: wrap;
      gap: .75rem;
    }

    .btn-hero {
      min-width: 200px;
      padding: .8rem 1.75rem;
      font-size: .82rem;
    }

    /* ── Footer ── */
    footer {
      border-top: 1px solid var(--border);
      background: var(--surface);
      padding: 1.5rem 2rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: .5rem;
    }

    footer p {
      font-family: 'DM Mono', monospace;
      font-size: .72rem;
      color: var(--ink-muted);
      letter-spacing: .04em;
    }

    footer a {
      font-family: 'DM Mono', monospace;
      font-size: .72rem;
      color: var(--ink-muted);
      text-decoration: none;
      letter-spacing: .04em;
    }
    footer a:hover { color: var(--accent); }

    /* ── Divider ── */
    .divider {
      border: none;
      border-top: 1px solid var(--border);
      margin: 0;
    }

    /* ── Responsive ── */
    @media (max-width: 500px) {
      header { padding: .75rem 1rem; }
      .hero { padding: 3rem 1rem 3rem; }
      .feature-grid { grid-template-columns: 1fr; }
      footer { flex-direction: column; align-items: flex-start; }
    }

    /* ── Layout ── */
    .Layout { max-width: 780px; margin: 0 auto; padding: 2.5rem 1.5rem 4rem;}

    h2 {
      font-size: 2rem;
      font-weight: 600;
      text-align: center;
      margin-bottom: 2rem;
      letter-spacing: -.02em;
    }

    /* ── Cards ── */
    .card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 1.5rem 1.75rem;
      box-shadow: var(--shadow);
      margin-bottom: 1.25rem;
    }

    .card-label {
      font-family: 'DM Mono', monospace;
      font-size: .7rem;
      letter-spacing: .12em;
      text-transform: uppercase;
      color: var(--ink-muted);
      margin-bottom: .6rem;
    }

    /* ── Features ── */
    .features {
      padding: 4rem 1.5rem 5rem;
    }

    .features-header {
      text-align: center;
      margin-bottom: 3rem;
    }

    .features-header h2 {
      font-size: 1.5rem;
      font-weight: 600;
      color: var(--ink);
      margin-bottom: .5rem;
    }

    .features-header p {
      color: var(--ink-muted);
      font-size: .95rem;
    }

    .feature-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 1.25rem;
      max-width: var(--max-w);
      margin: 0 auto;
    }

    .feature-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 1.75rem 1.5rem;
      transition: box-shadow .2s, transform .2s, border-color .2s;
    }

    .feature-card:hover {
      box-shadow: var(--shadow);
      transform: translateY(-2px);
      border-color: rgba(88,68,227,.25);
    }

    .feature-icon {
      width: 40px;
      height: 40px;
      background: var(--accent-lt);
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 1rem;
      font-size: 1.2rem;
    }

    .feature-card h3 {
      font-size: 1rem;
      font-weight: 600;
      color: var(--accent);
      margin-bottom: .5rem;
    }

    .feature-card p {
      font-size: .9rem;
      color: var(--ink-muted);
      line-height: 1.65;
    }

    /* ── Prompt area ── */
    .prompt-row {
      display: flex;
      align-items: flex-start;
      gap: 1rem;
    }

    #prompt-text {
      flex: 1;
      font-family: 'Lora', serif;
      font-size: 1rem;
      line-height: 1.65;
      color: var(--ink);
      min-height: 2.5rem;
      transition: opacity .25s;
    }

    #prompt-text.loading { opacity: .4; }

    /* ── Textarea ── */
    textarea {
      width: 100%;
      min-height: 160px;
      resize: vertical;
      font-family: 'Lora', serif;
      font-size: .97rem;
      line-height: 1.7;
      color: var(--ink);
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: .75rem 1rem;
      outline: none;
      transition: border-color .2s;
    }
    textarea:focus { border-color: var(--accent); }

    /* ── Buttons ── */
    .f-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: .4rem;
      font-family: 'DM Mono', monospace;
      font-size: .78rem;
      font-weight: 500;
      letter-spacing: .06em;
      padding: .6rem 1.25rem;
      border-radius: 6px;
      cursor: pointer;
      border: 1px solid transparent;
      text-decoration: none;
      transition: background .18s, color .18s, border-color .18s, transform .1s, box-shadow .18s;
      white-space: nowrap;
    }
    
    .btn {
      display: inline-flex;
      align-items: center;
      gap: .4rem;
      font-family: 'DM Mono', monospace;
      font-size: .78rem;
      letter-spacing: .06em;
      padding: .55rem 1.1rem;
      border-radius: 6px;
      cursor: pointer;
      border: 1px solid transparent;
      transition: background .18s, color .18s, transform .1s;
    }
    .btn:active { transform: translateY(1px); }

    .btn-outline {
      background: transparent;
      border-color: var(--border);
      color: var(--ink-muted);
    }
    .btn-outline:hover { background: var(--accent-lt); border-color: var(--accent); color: var(--accent); }

    .btn-primary {
      background: var(--accent);
      color: #fff;
      box-shadow: 0 2px 8px rgba(88,68,227,.25);
    }

    .btn-primary:hover {
      background: var(--accent-dark);
      box-shadow: 0 4px 16px rgba(88,68,227,.35);
      transform: translateY(-1px);
    }
    .btn-primary:active { transform: translateY(0); }
    .btn-primary:disabled { opacity: .55; cursor: not-allowed; }

    .submit-row {
      display: flex;
      justify-content: flex-end;
      margin-top: 1rem;
    }

    .front-btn {
      height: 50px;
      width: 330px;
      text-align: center
    }

    /* ── Error message ── */
    #error-msg {
      display: none;
      color: var(--danger);
      font-size: .85rem;
      margin-top: .5rem;
      font-family: 'DM Mono', monospace;
    }

    /* Prompt Choice Dialog*/
    dialog {
      padding: 0;
      border: none;
      border-radius: inherit;
      background: transparent;
      overflow: visible;
    }

    #results-modal {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(28,24,20,.45);
      backdrop-filter: blur(3px);
      z-index: 100;
      align-items: center;
      justify-content: center;
      padding: 1rem;
    }
    #results-modal.open { display: flex; }

    .modal-box {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 14px;
      box-shadow: 0 24px 60px rgba(0,0,0,.18);
      width: 100%;
      max-width: 600px;
      max-height: 88vh;
      overflow-y: auto;
      padding: 2rem 2.25rem 1.75rem;
      position: relative;
      animation: slideUp .28s ease;
    }

    .modal-actions {
      display: flex;
      justify-content: center; /* Centers items horizontally */
      align-items: center;     /* Centers items vertically (if the container has height) */
      gap: 12px;               /* Adds clean spacing between the buttons */
    }

    dialog {
      margin: auto;
      position: fixed; 
      inset: 0;
      /*Blurs background*/
      backdrop-filter: blur(3px);
    }

    #myPopup {
      /* Fixes the positioning relative to the screen */
      position: fixed; 
      top: 50%;
      left: 50%;
  
      /* Shifts the element back by half its own width and height to perfectly center it */
      transform: translate(-50%, -50%); 
  
      /* Reset default browser dialog borders/paddings if necessary */
      border: none;
      padding: 0;
      background: transparent;
    }

    @keyframes slideUp {
      from { opacity: 0; transform: translateY(18px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    .modal-close {
      position: absolute;
      top: 1rem; right: 1.25rem;
      background: none;
      border: none;
      font-size: 1.4rem;
      color: var(--ink-muted);
      cursor: pointer;
      line-height: 1;
    }
    .modal-close:hover { color: var(--ink); }

    .modal-title {
      font-size: 1.35rem;
      font-weight: 600;
      margin-bottom: .25rem;
    }
    .modal-prompt {
      font-size: .82rem;
      color: var(--ink-muted);
      font-family: 'DM Mono', monospace;
      margin-bottom: 1.5rem;
      line-height: 1.4;
    }

    /* ── Score ring ── */
    .score-hero {
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 1.75rem;
    }
    .score-ring {
      width: 110px; height: 110px;
      border-radius: 50%;
      background: conic-gradient(var(--accent) 0% var(--pct, 0%), var(--accent-lt) var(--pct, 0%) 100%);
      display: flex;
      align-items: center;
      justify-content: center;
      font-family: 'DM Mono', monospace;
      font-size: 1.5rem;
      font-weight: 500;
      position: relative;
    }
    .score-ring::before {
      content: '';
      position: absolute;
      inset: 10px;
      border-radius: 50%;
      background: var(--surface);
    }
    .score-ring span { position: relative; z-index: 1; }

    /* ── Metrics grid ── */
    .metrics { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; margin-bottom: 1.25rem; }

    .metric-card {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: .85rem 1rem;
    }
    .metric-label {
      font-family: 'DM Mono', monospace;
      font-size: .65rem;
      letter-spacing: .1em;
      text-transform: uppercase;
      color: var(--ink-muted);
      margin-bottom: .3rem;
    }
    .metric-value {
      font-size: 1.35rem;
      font-weight: 600;
      color: var(--accent);
      font-family: 'DM Mono', monospace;
    }

    /* ── Bar rows ── */
    .breakdown { margin-bottom: 1.25rem; }
    .breakdown-title {
      font-family: 'DM Mono', monospace;
      font-size: .7rem;
      letter-spacing: .1em;
      text-transform: uppercase;
      color: var(--ink-muted);
      margin-bottom: .65rem;
    }
    .bar-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .45rem; }
    .bar-row-label { font-size: .82rem; color: var(--ink-muted); width: 160px; flex-shrink: 0; }
    .bar-track { flex: 1; height: 6px; background: var(--accent-lt); border-radius: 99px; }
    .bar-fill  { height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
    .bar-num   { font-family: 'DM Mono', monospace; font-size: .75rem; color: var(--ink-muted); width: 30px; text-align: right; }

    /* ── Suggestions ── */
    .suggestions { border-top: 1px solid var(--border); padding-top: 1rem; }
    .suggestions-title {
      font-family: 'DM Mono', monospace;
      font-size: .7rem;
      letter-spacing: .1em;
      text-transform: uppercase;
      color: var(--ink-muted);
      margin-bottom: .6rem;
    }
    .suggestion-item {
      font-size: .88rem;
      line-height: 1.55;
      color: var(--ink-muted);
      padding: .35rem 0 .35rem .9rem;
      border-left: 2px solid var(--accent);
      margin-bottom: .45rem;
    }

    /* ── Spinner ── */
    .spinner {
      display: inline-block;
      width: 14px; height: 14px;
      border: 2px solid rgba(255,255,255,.4);
      border-top-color: #fff;
      border-radius: 50%;
      animation: spin .6s linear infinite;
    }
    @keyframes spin { to { transform: rotate(360deg); } }