* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #000000;
  --text: #ffffff;
  --text-muted: #666666;
  --accent: #ffffff;
  --border: #222222;
}

body {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  line-height: 1.5;
  overflow: hidden;
}

.container {
  max-width: 720px;
  width: 100%;
}

header {
  position: fixed;
  top: 3rem;
  left: 3rem;
  right: 3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.date {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 500;
}

h1 {
  display: none;
}

.word-card {
  background: transparent;
  border: none;
  padding: 0;
}

.type {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #000;
  background: var(--text);
  padding: 0.375rem 0.75rem;
  margin-bottom: clamp(0.75rem, 2vh, 1.5rem);
}

.word-header {
  display: block;
  margin-bottom: clamp(1rem, 3vh, 2rem);
}

.word {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  display: block;
}

.part-of-speech {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: clamp(0.5rem, 1.5vh, 1rem);
  display: block;
}

.pronunciation {
  display: none;
}

.definition {
  font-size: clamp(0.9rem, 2vw, 1.125rem);
  margin-bottom: clamp(1.5rem, 4vh, 3rem);
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.6;
  max-width: 560px;
}

.example {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-style: normal;
  font-weight: 500;
  color: var(--text);
  border-left: 2px solid var(--accent);
  padding-left: clamp(1rem, 3vw, 2rem);
  margin: 0 0 clamp(1.5rem, 4vh, 3rem) 0;
  line-height: 1.6;
}

.origin {
  font-size: clamp(0.75rem, 1.5vw, 0.8125rem);
  color: var(--text-muted);
  padding-top: clamp(1rem, 3vh, 2rem);
  border-top: 1px solid var(--border);
  line-height: 1.6;
}

.origin::before {
  content: 'Origin — ';
  font-weight: 600;
  color: var(--text);
}

footer {
  position: fixed;
  top: 3rem;
  right: 3rem;
  display: flex;
  gap: 1rem;
  z-index: 10;
}

.btn {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 1rem 1.5rem;
  border: 1px solid var(--text);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--text);
  color: var(--bg);
}

.btn-secondary {
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-secondary:hover {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

/* Archive Modal */
.archive-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 100;
}

.archive-modal.open {
  display: flex;
}

.archive-content {
  background: var(--bg);
  border: 1px solid var(--border);
  max-width: 500px;
  width: 100%;
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.archive-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.archive-header h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem;
}

.close-btn:hover {
  color: var(--text);
}

.archive-list {
  list-style: none;
  overflow-y: auto;
  padding: 0;
}

.archive-list li {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
}

.archive-list li:last-child {
  border-bottom: none;
}

.archive-list li:hover {
  background: #111;
}

.archive-list .archive-word {
  font-size: 1rem;
  font-weight: 600;
}

.archive-list .archive-date {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-right: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.05em;
}

.archive-list .archive-preview {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Touch feedback for all interactive elements */
@media (hover: none) {
  .btn:active {
    background: var(--text);
    color: var(--bg);
  }

  .btn-secondary:active {
    border-color: var(--text);
    background: var(--text);
    color: var(--bg);
  }

  .archive-list li:active {
    background: #111;
  }
}

@media (max-width: 640px) {
  body {
    padding: 4.5rem 1.25rem 5.5rem;
    padding-top: calc(4.5rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    padding-left: calc(1.25rem + env(safe-area-inset-left, 0px));
    padding-right: calc(1.25rem + env(safe-area-inset-right, 0px));
    align-items: flex-start;
  }

  .container {
    max-width: 100%;
    max-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .container::-webkit-scrollbar {
    display: none;
  }

  header {
    top: 1.25rem;
    top: calc(1.25rem + env(safe-area-inset-top, 0px));
    left: 1.25rem;
    left: calc(1.25rem + env(safe-area-inset-left, 0px));
    right: auto;
  }

  /* Move buttons to bottom thumb zone */
  footer {
    top: auto;
    bottom: 1.25rem;
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    left: 1.25rem;
    left: calc(1.25rem + env(safe-area-inset-left, 0px));
    right: 1.25rem;
    right: calc(1.25rem + env(safe-area-inset-right, 0px));
    gap: 0.75rem;
  }

  /* 44px minimum touch targets */
  .btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1.25rem;
    font-size: 0.6875rem;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .word {
    font-size: clamp(1.5rem, 7vw, 2.25rem);
  }

  .definition {
    font-size: 0.875rem;
    max-width: 100%;
  }

  .example {
    font-size: 0.9375rem;
    padding-left: 1rem;
  }

  .origin {
    font-size: 0.75rem;
  }

  /* Full-screen archive on mobile */
  .archive-modal {
    padding: 0;
  }

  .archive-content {
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border: none;
  }

  .archive-header {
    padding: 1.25rem;
    padding-top: calc(1.25rem + env(safe-area-inset-top, 0px));
  }

  .close-btn {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
  }

  .archive-list li {
    padding: 1rem 1.25rem;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

@media (max-width: 380px) {
  body {
    padding-top: calc(3.5rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
    padding-left: calc(1rem + env(safe-area-inset-left, 0px));
    padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  }

  header {
    top: calc(1rem + env(safe-area-inset-top, 0px));
    left: calc(1rem + env(safe-area-inset-left, 0px));
  }

  footer {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: calc(1rem + env(safe-area-inset-left, 0px));
    right: calc(1rem + env(safe-area-inset-right, 0px));
  }

  .word {
    font-size: clamp(1.375rem, 6.5vw, 2rem);
  }

  .type {
    font-size: 0.5625rem;
    padding: 0.25rem 0.5rem;
  }

  .definition {
    font-size: 0.8125rem;
    margin-bottom: 1rem;
  }

  .example {
    font-size: 0.875rem;
    margin-bottom: 1rem;
  }

  .origin {
    font-size: 0.6875rem;
    padding-top: 0.75rem;
  }
}
