@font-face {
  font-family: 'Ravi VF';
  src: url('/Ravi-VF.ttf') format('truetype');
  font-weight: 100 900;
  font-stretch: 50 200;
}

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

:root {
  --bg: #ffffff;
  --text: #333333;
  --text-light: #666666;
  --accent: #000000;
  --error: #ff3b30;
  --border: #e5e5e5;
  --bg-hover: #f5f5f5;
  --font-family: 'Ravi VF', system-ui, -apple-system, sans-serif;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

.container {
  max-width: 65ch;
  margin: 0 auto;
  padding: 1.5rem 1.5rem;
}

body.has-header .container {
  padding-top: 4.5rem;
}

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}



.header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-logo {
  display: flex;
  align-items: center;
}

.header-logo svg {
  width: 32px;
  height: 32px;
}

.header-title h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.header-subtitle {
  font-size: 0.875rem;
  color: var(--text-light);
  margin: 0;
  margin-left: 4rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 2rem;
  text-align: right;
}

label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
  text-align: right;
}

input,
textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  font-family: var(--font-family);
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  min-height: 200px;
  resize: vertical;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 1.5rem;
}

#createForm {
  margin-bottom: 3rem;
}

.encryption-toggle {
  display: flex;
  align-items: center;
  opacity: 0.4;
  pointer-events: none;
}

.switch-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  cursor: pointer;
}

.switch-label input {
  display: none;
}

.switch-slider {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 24px;
  position: relative;
  transition: background 0.2s;
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}

.switch-label input:checked + .switch-slider {
  background: var(--accent);
}

.switch-label input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.secret-section {
  margin-bottom: 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.5rem;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-secondary {
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
}

.btn-outline {
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  text-decoration: none;
}

.thread-footer .btn-outline {
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.share-box {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1.5rem;
  text-align: center;
}

.share-box label {
  margin-bottom: 0.5rem;
  text-align: center;
}

.share-link {
  display: block;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
  word-break: break-all;
  margin-bottom: 0.5rem;
}

.copy-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.letter {
  padding: 1.5rem 0;
}

.letter:first-child {
  padding-top: 0;
  min-height: 60vh;
}

.letter:first-child .letter-body {
  font-size: 1.0625rem;
  line-height: 2;
}

.letter + .letter {
  position: relative;
}

.letter + .letter::before {
  content: '· · ·';
  display: block;
  text-align: center;
  color: var(--text-light);
  font-size: 0.875rem;
  letter-spacing: 0.5em;
  margin-bottom: 1.5rem;
}

.letter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.letter-from {
  font-size: 0.9375rem;
}

.letter-time {
  font-size: 0.8125rem;
  color: var(--text-light);
}

.letter-from-label {
  color: var(--text-light);
  font-weight: normal;
}

.letter-from-name {
  font-weight: 600;
}

.letter-body {
  white-space: pre-wrap;
  line-height: 1.9;
  margin-top: 1.5rem;
}

.thread-subject {
  font-size: 1.375rem;
  font-weight: 600;
  margin-bottom: 2.5rem;
  padding-bottom: 1.25rem;
  text-align: center;
  position: relative;
}

.thread-header {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;
}

.menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  padding: 0.5rem;
  border-radius: 8px;
}

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

.menu-btn svg {
  width: 20px;
  height: 20px;
}

.menu-popup {
  position: fixed;
  top: 3rem;
  right: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  z-index: 100;
  min-width: 180px;
  overflow: hidden;
}

.menu-popup.hidden {
  display: none;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-family);
  font-size: 0.9375rem;
  text-align: right;
}

.menu-item:hover {
  background: var(--bg-hover);
}

.menu-item svg {
  color: var(--text-light);
}

.thread-subject::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 50%;
  transform: translateX(50%);
  width: 15rem;
  height: 1px;
  background: var(--border);
}

.reply-section {
  padding: 0.75rem 1.5rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  border-bottom: 1px solid var(--border);
}

.submit-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem 1.5rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 5;
}

.reply-btn {
  display: block;
  width: 100%;
  padding: 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-light);
  font-family: var(--font-family);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, color 0.2s;
}

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

.reply-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: var(--border);
  color: var(--text-light);
}



.lock-screen {
  text-align: center;
  padding: 3rem 1rem;
}

.lock-screen h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.lock-screen p {
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

.error-message {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  text-align: center;
}

.hidden {
  display: none;
}

.textarea-wrapper {
  position: relative;
}

.textarea-wrapper textarea {
  padding-top: 2.5rem;
}

.fullscreen-btn {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  padding: 0.25rem;
  border-radius: 4px;
  opacity: 0.7;
}

.fullscreen-btn:hover {
  background: var(--bg-hover);
  opacity: 1;
}

.fullscreen-btn svg {
  width: 18px;
  height: 18px;
}

.fullscreen-editor {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.fullscreen-editor.hidden {
  display: none;
}

.fullscreen-editor-header {
  padding: 1rem;
  display: flex;
  direction: ltr;
}

.fullscreen-editor-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  padding: 0.375rem;
  border-radius: 6px;
  opacity: 0.7;
}

.fullscreen-editor-close:hover {
  background: var(--bg-hover);
  opacity: 1;
}

.fullscreen-editor-close svg {
  width: 18px;
  height: 18px;
}

.fullscreen-body {
  flex: 1;
  width: 100%;
  border: none;
  resize: none;
  padding: 1rem 1.5rem;
  font-family: var(--font-family);
  font-size: 1.125rem;
  line-height: 1.8;
  background: transparent;
  color: var(--text);
}

.fullscreen-body:focus {
  outline: none;
}

.fullscreen-body::placeholder {
  color: var(--text-light);
}

.fullscreen-editor-footer {
  padding: 1rem 1.5rem;
}

.fullscreen-editor-footer .btn {
  width: 100%;
}

.optional-note {
  font-size: 0.8125rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  text-align: center;
}

.reply-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 2rem 1.5rem 1.5rem;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  animation: slideUp 0.3s ease;
}

.reply-sheet-close {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--text-light);
}

.reply-sheet-close svg {
  width: 20px;
  height: 20px;
}

.reply-sheet h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0.5rem 0 1rem;
  text-align: center;
}

.reply-sheet .btn-primary {
  width: 100%;
}

@media (min-width: 768px) {
  .container {
    padding: 3rem 2rem;
    padding-bottom: 6rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  .btn-primary {
    width: auto;
    min-width: 200px;
  }

  .reply-section {
    max-width: 65ch;
    left: 50%;
    transform: translateX(-50%);
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .submit-bar {
    max-width: 65ch;
    left: 50%;
    transform: translateX(-50%);
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.thread-footer {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.625rem;
  color: #b0b0b0;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.footer-credits {
  position: relative;
}

.info-btn-footer {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  color: #b0b0b0;
  padding: 0;
  margin-left: 0.5rem;
}

.info-btn-footer:hover {
  color: #888;
}

.thread-footer a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.thread-footer a:hover {
  opacity: 0.7;
}

.share-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 2rem 1.5rem 1.5rem;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  animation: slideUp 0.3s ease;
  z-index: 10;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.share-sheet-close {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--text-light);
}

.share-sheet-close svg {
  width: 20px;
  height: 20px;
}

.share-sheet h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0.5rem 0 0.25rem;
  text-align: center;
}

.share-sheet-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
  color: var(--text);
}

.share-sheet-icon svg {
  width: 32px;
  height: 32px;
}

.share-sheet p {
  color: var(--text-light);
  font-size: 0.875rem;
  text-align: center;
  margin-bottom: 1rem;
}

.share-sheet .share-link {
  font-family: monospace;
  direction: ltr;
  text-align: center;
  padding: 0.75rem;
  background: #f5f5f5;
  border-radius: 8px;
  font-size: 0.875rem;
  word-break: break-all;
  margin-bottom: 1rem;
}

.share-actions {
  display: flex;
  gap: 0.75rem;
}

.share-actions .btn {
  flex: 1;
}

.share-actions .btn-primary {
  order: 2;
}

.share-actions .btn-secondary {
  order: 1;
}

.info-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  flex-shrink: 0;
}

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

.info-btn svg {
  width: 20px;
  height: 20px;
}

.info-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 2rem 1.5rem 1.5rem;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  animation: slideUp 0.3s ease;
  z-index: 10;
}

.info-sheet-close {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--text-light);
}

.info-sheet-close svg {
  width: 20px;
  height: 20px;
}

.info-sheet h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0.5rem 0 1.25rem;
  text-align: center;
}

.info-section {
  margin-bottom: 1.25rem;
}

.info-section h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--text);
}

.info-section p {
  font-size: 0.875rem;
  color: var(--text-light);
  line-height: 1.7;
}
