:root {
      --desk: #e6e4de;
      --paper: #f4f3ef;
      --ink: #121211;
      --mid: #4a4945;
      --muted: #75746f;
      --soft: #a3a29d;
      --rule: #d2d1cb;
      --stamp: #a8321f;
      --field: rgba(18, 18, 17, 0.055);
      --font: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

      --ink-blue: #325b99;
      --ink-green: #376b42;
      --ink-gold: #9e7314;
      --ink-purple: #6d478f;
      
      --bg-blue: rgba(50, 91, 153, 0.08);
      --bg-green: rgba(55, 107, 66, 0.08);
      --bg-gold: rgba(158, 115, 20, 0.08);

      --text-main: var(--ink);
      --text-muted: var(--muted);
      --text-dim: var(--soft);
      --border-subtle: var(--rule);
      --primary: var(--ink);
      --danger: var(--stamp);
      --radius-sm: 2px;
      
      --ease-out-gentle: cubic-bezier(0.16, 1, 0.3, 1);
    }

    [data-theme="dark"] {
      --desk: #0c0c0b;
      --paper: #1a1a18;
      --ink: #efeee9;
      --mid: #c5c4be;
      --muted: #8d8c86;
      --soft: #62615c;
      --rule: #34342f;
      --stamp: #ff8f70;
      --field: rgba(255, 255, 255, 0.06);

      --ink-blue: #86b2ff;
      --ink-green: #81cf93;
      --ink-gold: #f2c14e;
      --ink-purple: #c79ff5;

      --bg-blue: rgba(134, 178, 255, 0.12);
      --bg-green: rgba(129, 207, 147, 0.12);
      --bg-gold: rgba(242, 193, 78, 0.12);

    }

    * { 
      box-sizing: border-box; 
      margin: 0; 
      padding: 0; 
      -webkit-tap-highlight-color: transparent; 
    }

    /* Minimal Scrollbar */
    * {
      scrollbar-width: thin;
      scrollbar-color: var(--rule) transparent;
    }
    ::-webkit-scrollbar {
      width: 5px;
      height: 5px;
    }
    ::-webkit-scrollbar-track {
      background: transparent;
    }
    ::-webkit-scrollbar-thumb {
      background: var(--rule);
      border-radius: 99px;
      border: 1px solid transparent;
      background-clip: padding-box;
      transition: background 0.15s ease;
    }
    ::-webkit-scrollbar-thumb:hover {
      background: var(--soft);
    }
    ::-webkit-scrollbar-thumb:active {
      background: var(--mid);
    }

    /* Screen-Fit Viewport Rules */
    html { 
      -webkit-text-size-adjust: 100%; 
      background: var(--desk);
      height: 100%;
      height: 100dvh;
      overflow: hidden;
    }

    body {
      font-family: var(--font);
      font-size: 13px;
      line-height: 1.5;
      background: var(--desk);
      color: var(--ink);
      height: 100%;
      height: 100dvh;
      width: 100vw;
      max-width: 100vw;
      overflow: hidden;
      display: flex;
      justify-content: center;
      align-items: stretch;
      -webkit-font-smoothing: antialiased;
      font-variant-numeric: slashed-zero;
    }

    .container { 
      width: 100%; 
      max-width: 520px; 
      min-width: 0; 
      height: 100%;
      height: 100dvh;
      max-height: 100dvh;
      display: flex;
      flex-direction: column;
      position: relative;
      overflow: hidden;
      background: var(--paper);
      box-shadow: 0 0 35px rgba(0, 0, 0, 0.08);
      border-left: 1px solid var(--rule);
      border-right: 1px solid var(--rule);
    }

    @keyframes smoothCardEnter {
      0% {
        opacity: 0;
        transform: translateY(14px) scale(0.99);
      }
      100% {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }

    @keyframes smoothFadeUp {
      0% {
        opacity: 0;
        transform: translateY(8px);
      }
      100% {
        opacity: 1;
        transform: translateY(0);
      }
    }

    @keyframes smoothTileEnter {
      0% {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
      }
      100% {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }

    @keyframes shakeError {
      0%, 100% { transform: translateX(0); }
      20%, 60% { transform: translateX(-6px); }
      40%, 80% { transform: translateX(6px); }
    }

    .card {
      position: relative;
      background: var(--paper);
      width: 100%;
      height: 100%;
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
      margin: 0;
      box-sizing: border-box;
      animation: smoothCardEnter 0.45s var(--ease-out-gentle) both;
      will-change: transform, opacity;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior-y: contain;
      padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    }

    /* Perforated Receipt Teeth */
    .card::before {
      content: '';
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      height: 8px;
      pointer-events: none;
      background: radial-gradient(circle at 6px 0, var(--desk) 4px, transparent 4.5px) 0 0/12px 8px repeat-x;
      z-index: 45;
    }

    .anim-header {
      animation: smoothFadeUp 0.4s var(--ease-out-gentle) 0.08s both;
    }

    h1 {
      font-size: 15px;
      font-weight: 700;
      letter-spacing: 0.01em;
      text-transform: uppercase;
      margin-bottom: 4px;
      text-align: center;
    }
    p.subtitle {
      color: var(--muted);
      font-size: 12px;
      margin-bottom: 16px;
      line-height: 1.5;
      text-align: center;
    }
    .section-title {
      font-size: 11px;
      font-weight: 400;
      text-transform: uppercase;
      color: var(--soft);
      margin-bottom: 10px;
    }
    .hidden { display: none !important; }

    .nav-breadcrumbs {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      flex-wrap: wrap;
      padding-bottom: 10px;
      margin-bottom: 14px;
      border-bottom: 1px dashed var(--soft);
      font-size: 12px;
      animation: smoothFadeUp 0.4s var(--ease-out-gentle) 0.05s both;
    }
    .nav-back-link {
      display: inline-flex;
      align-items: center;
      font: inherit;
      color: var(--muted);
      text-decoration: none;
      cursor: pointer;
      background: none;
      border: 0;
      padding: 4px 0;
      min-height: 30px;
      transition: color 0.15s ease;
    }
    .nav-back-link:hover { color: var(--ink); }

    .tag {
      display: inline-block;
      padding: 1px 8px;
      font-size: 11px;
      font-weight: 700;
      border: 1px solid var(--ink);
      border-radius: var(--radius-sm);
      text-transform: uppercase;
    }

    .btn-theme-toggle {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 4px 8px;
      font-size: 13px;
      line-height: 1;
      min-height: 30px;
      min-width: 30px;
      border: 1px solid var(--soft);
      background: transparent;
      color: var(--ink);
      border-radius: 2px;
      cursor: pointer;
      user-select: none;
      transition: all 0.15s ease;
    }
    .btn-theme-toggle:hover {
      border-color: var(--ink);
      background: var(--field);
    }

    .app-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
      gap: 8px;
      margin-top: 6px;
    }

    .app-tile {
      background: var(--field);
      border: 1px dashed var(--soft);
      border-radius: var(--radius-sm);
      padding: 16px 10px 14px;
      text-align: center;
      cursor: pointer;
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: flex-start;
      user-select: none;
      animation: smoothTileEnter 0.4s var(--ease-out-gentle) calc(0.08s + (var(--i, 0) * 0.025s)) both;
      transition: border 0.15s ease, background 0.15s ease, transform 0.18s cubic-bezier(0.2, 0.8, 0.4, 1), box-shadow 0.18s ease;
      will-change: transform, opacity;
    }

    .app-tile:hover {
      border: 1px solid var(--ink);
      background: var(--paper);
      transform: translateY(-2px);
      box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    }

    .app-tile:nth-child(4n+1) .app-tile-icon { color: var(--ink-blue); }
    .app-tile:nth-child(4n+2) .app-tile-icon { color: var(--ink-green); }
    .app-tile:nth-child(4n+3) .app-tile-icon { color: var(--ink-gold); }
    .app-tile:nth-child(4n+4) .app-tile-icon { color: var(--ink-purple); }

    .app-tile:nth-child(4n+1):hover { border-color: var(--ink-blue); background: var(--bg-blue); }
    .app-tile:nth-child(4n+2):hover { border-color: var(--ink-green); background: var(--bg-green); }
    .app-tile:nth-child(4n+3):hover { border-color: var(--ink-gold); background: var(--bg-gold); }
    .app-tile:nth-child(4n+4):hover { border-color: var(--ink-purple); }

    .app-tile:active { 
      transform: translateY(1px) scale(0.99); 
      box-shadow: none;
    }

    /* Vector Icon Container */
    .app-tile-icon {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 34px;
      height: 34px;
      margin-bottom: 8px;
      color: inherit;
      transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    }
    .app-tile-icon svg {
      width: 26px;
      height: 26px;
      stroke-width: 1.75px;
      stroke: currentColor;
    }
    .app-tile:hover .app-tile-icon {
      transform: scale(1.12);
    }

    .app-tile-title {
      font-size: 12px;
      font-weight: 700;
      color: var(--ink);
      margin-bottom: 3px;
      text-transform: uppercase;
      letter-spacing: 0.02em;
    }

    .app-tile-desc {
      font-size: 10.5px;
      color: var(--muted);
      line-height: 1.35;
    }

    .app-tile-lock {
      position: absolute;
      top: 6px;
      right: 6px;
      font-size: 9px;
      font-weight: 700;
      border: 1px solid var(--stamp);
      color: var(--stamp);
      padding: 0 4px;
      border-radius: var(--radius-sm);
      line-height: 1.3;
    }

    .input-group { margin-bottom: 16px; }
    label {
      display: block;
      font-size: 11px;
      font-weight: 400;
      margin-bottom: 6px;
      color: var(--muted);
      text-transform: uppercase;
    }
    input {
      width: 100%;
      font: inherit;
      font-size: 16px;
      background: var(--field);
      border: 0;
      border-bottom: 1px dashed var(--soft);
      border-radius: 0;
      color: var(--ink);
      padding: 10px 8px;
      outline: none;
      min-height: 44px;
      transition: border-bottom-color 0.15s ease, background 0.15s ease;
    }
    input:focus {
      border-bottom: 1px solid var(--ink);
      background: transparent;
      box-shadow: 0 2px 0 var(--ink);
    }
    input::placeholder { color: var(--soft); }
    .internal-password { -webkit-text-security: disc; }

    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 10px 14px;
      border-radius: var(--radius-sm);
      font: inherit;
      font-weight: 700;
      font-size: 12px;
      cursor: pointer;
      border: 1px solid var(--ink);
      user-select: none;
      min-height: 42px;
      background: transparent;
      color: var(--ink);
      transition: background 0.15s ease, transform 0.1s ease;
    }
    .btn:active { transform: translateY(1px); }
    .btn-primary { background: var(--ink); color: var(--paper); }
    .btn-primary:hover { opacity: 0.92; }

    .shake {
      animation: shakeError 0.4s ease-in-out;
    }

    button:focus-visible, a:focus-visible, .app-tile:focus-visible {
      outline: 2px solid var(--ink);
      outline-offset: 2px;
    }

    .footer-note {
      margin-top: auto;
      padding-top: 20px;
      border-top: 1px dashed var(--soft);
      text-align: center;
      font-size: 11px;
      color: var(--soft);
      animation: smoothFadeUp 0.4s var(--ease-out-gentle) 0.3s both;
    }

    @media (max-width: 480px) {
      .card { padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)); }
      .app-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
      .app-tile { padding: 12px 6px; }
    }
    @media (prefers-reduced-motion: reduce) {
      * { animation: none !important; transition: none !important; }
    }
